1 // =========================
2 // CSQC Monster Properties
3 // =========================
7 void monster_changeteam()
9 self.glowmod = Team_ColorRGB(self.team - 1);
13 self.teamradar_color = Team_ColorRGB(self.team - 1);
14 self.colormap = 1024 + (self.team - 1) * 17;
18 self.teamradar_color = '1 0 0';
25 MON_ACTION(self.monsterid, MR_DEATH);
27 self.solid = SOLID_CORPSE;
32 if(self.netname == "")
35 if(!autocvar_g_waypointsprite_monsters)
38 if(autocvar_cl_hidewaypoints)
44 float dist = vlen(self.origin - view_origin);
45 float t = (GetPlayerColor(player_localnum) + 1);
50 if(autocvar_cl_vehicles_hud_tactical)
51 if(dist < 10240 && t != self.team)
53 // TODO: Vehicle tactical hud
54 o = project_3d_to_2d(self.origin + '0 0 1' * ((self.maxs_z + self.mins_z) * 0.5));
56 || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
57 || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
58 || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
59 || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
60 return; // Dont draw wp's for monsters out of view
70 vector pz = drawgetimagesize("gfx/vehicles/vth-mover.tga") * 0.25;
71 drawpic(o - pz * 0.5, "gfx/vehicles/vth-mover.tga", pz , '1 1 1', 0.75, DRAWFLAG_NORMAL);
77 if(dist > self.maxdistance)
80 string spriteimage = self.netname;
81 float a = self.alpha * autocvar_hud_panel_fg_alpha;
82 vector rgb = spritelookupcolor(spriteimage, self.teamradar_color);
85 if(self.maxdistance > waypointsprite_normdistance)
86 a *= pow(bound(0, (self.maxdistance - dist) / (self.maxdistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent);
87 else if(self.maxdistance > 0)
88 a *= pow(bound(0, (waypointsprite_fadedistance - dist) / (waypointsprite_fadedistance - waypointsprite_normdistance), 1), waypointsprite_distancealphaexponent) * (1 - waypointsprite_minalpha) + waypointsprite_minalpha;
92 self.teamradar_color = '1 0 0';
93 print(sprintf("WARNING: sprite of name %s has no color, using red so you notice it\n", spriteimage));
97 if(autocvar_g_waypointsprite_spam && waypointsprite_count >= autocvar_g_waypointsprite_spam)
100 txt = spritelookuptext(spriteimage);
102 if(autocvar_g_waypointsprite_uppercase)
103 txt = strtoupper(txt);
114 rgb = fixrgbexcess(rgb);
116 o = project_3d_to_2d(self.origin + '0 0 1' * (self.maxs_z + 15));
118 || o_x < (vid_conwidth * waypointsprite_edgeoffset_left)
119 || o_y < (vid_conheight * waypointsprite_edgeoffset_top)
120 || o_x > (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right))
121 || o_y > (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)))
122 return; // Dont draw wp's for monsters out of view
126 float edgedistance_min, crosshairdistance;
127 edgedistance_min = min((o_y - (vid_conheight * waypointsprite_edgeoffset_top)),
128 (o_x - (vid_conwidth * waypointsprite_edgeoffset_left)),
129 (vid_conwidth - (vid_conwidth * waypointsprite_edgeoffset_right)) - o_x,
130 (vid_conheight - (vid_conheight * waypointsprite_edgeoffset_bottom)) - o_y);
132 float vidscale = max(vid_conwidth / vid_width, vid_conheight / vid_height);
134 crosshairdistance = sqrt( pow(o_x - vid_conwidth/2, 2) + pow(o_y - vid_conheight/2, 2) );
136 t = waypointsprite_scale * vidscale;
137 a *= waypointsprite_alpha;
140 a = a * (1 - (1 - waypointsprite_distancefadealpha) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
141 t = t * (1 - (1 - waypointsprite_distancefadescale) * (bound(0, dist/waypointsprite_distancefadedistance, 1)));
143 if (edgedistance_min < waypointsprite_edgefadedistance) {
144 a = a * (1 - (1 - waypointsprite_edgefadealpha) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
145 t = t * (1 - (1 - waypointsprite_edgefadescale) * (1 - bound(0, edgedistance_min/waypointsprite_edgefadedistance, 1)));
147 if(crosshairdistance < waypointsprite_crosshairfadedistance) {
148 a = a * (1 - (1 - waypointsprite_crosshairfadealpha) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
149 t = t * (1 - (1 - waypointsprite_crosshairfadescale) * (1 - bound(0, crosshairdistance/waypointsprite_crosshairfadedistance, 1)));
152 draw_beginBoldFont();
153 o = drawspritearrow(o, M_PI, rgb, a, SPRITE_ARROW_SCALE * t);
154 o = drawspritetext(o, M_PI, (SPRITE_HEALTHBAR_WIDTH + 2 * SPRITE_HEALTHBAR_BORDER) * t, rgb, a, waypointsprite_fontsize * '1 1 0', txt);
161 0.5 * SPRITE_HEALTHBAR_WIDTH * t,
162 0.5 * SPRITE_HEALTHBAR_HEIGHT * t,
163 SPRITE_HEALTHBAR_MARGIN * t + 0.5 * waypointsprite_fontsize,
164 SPRITE_HEALTHBAR_BORDER * t,
167 a * SPRITE_HEALTHBAR_BORDERALPHA,
169 a * SPRITE_HEALTHBAR_HEALTHALPHA,
179 dt = time - self.move_time;
180 self.move_time = time;
184 fixedmakevectors(self.angles);
185 //movelib_groundalign4point(50, 25, 0.25, 45);
186 setorigin(self, self.origin + self.velocity * dt);
187 self.angles_y = self.move_angles_y;
190 void monster_construct()
192 entity mon = get_monsterinfo(self.monsterid);
194 if(mon.spawnflags & MONSTER_SIZE_BROKEN)
197 self.netname = M_NAME(self.monsterid);
199 setorigin(self, self.origin);
200 setmodel(self, mon.model);
201 setsize(self, mon.mins, mon.maxs);
203 self.move_movetype = MOVETYPE_BOUNCE;
205 self.solid = SOLID_BBOX;
206 self.movetype = MOVETYPE_BOUNCE;
207 self.move_origin = self.origin;
208 self.move_time = time;
209 self.drawmask = MASK_NORMAL;
212 self.draw = monster_draw;
213 self.draw2d = monster_draw2d;
214 self.maxdistance = autocvar_g_waypointsprite_monsters_maxdist;
224 self.monsterid = ReadByte();
226 self.origin_x = ReadCoord();
227 self.origin_y = ReadCoord();
228 self.origin_z = ReadCoord();
229 setorigin(self, self.origin);
231 self.angles_x = ReadAngle();
232 self.angles_y = ReadAngle();
234 self.skin = ReadByte();
235 self.team = ReadByte();
238 monster_changeteam();
243 self.move_angles_x = ReadShort();
244 self.move_angles_y = ReadShort();
245 self.angles = self.move_angles;
250 self.origin_x = ReadShort();
251 self.origin_y = ReadShort();
252 self.origin_z = ReadShort();
253 setorigin(self, self.origin);
255 self.velocity_x = ReadShort();
256 self.velocity_y = ReadShort();
257 self.velocity_z = ReadShort();
259 self.move_angles_y = ReadShort();
261 self.move_time = time;
262 self.move_velocity = self.velocity;
263 self.move_origin = self.origin;
268 self.frame1time = ReadCoord();
269 self.frame = ReadByte();
274 self.skin = ReadByte();
278 if(_tmp != self.team)
281 monster_changeteam();
285 if(_tmp == 4) // respawning
286 setmodel(self, "null");
290 if(_tmp == 0 && self.health != 0)