00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 void snap_extnav_osd();
00032 float snap_extnav_osd_check(vector v_start, vector v_off);
00033 void snap_extnav_osd_sound();
00034 void snap_extnav_compass();
00035
00036
00037
00038
00049 void snap_extnav_osd()
00050 {
00051 local float do_sound, cycle_time, skipover_time;
00052 local vector v_start;
00053 v_start = self.owner.origin - '0 0 20';
00054
00055
00056 cycle_time = 0.5;
00057 skipover_time = 0;
00058
00059
00060 if( self.frags == 0 )
00061 {
00062 makevectors(self.owner.angles);
00063 self.frags = 1;
00064 self.nextthink = time + skipover_time;
00065 setmodel(self, "progs/s_explod.spr");
00066 }
00067 else if( self.frags == 1 )
00068 {
00069
00070 do_sound = snap_extnav_osd_check(v_start, (v_start - self.health * v_right));
00071 if( do_sound > 0 )
00072 {
00073 setorigin(self, trace_endpos);
00074 snap_extnav_osd_sound();
00075 self.nextthink = time + cycle_time;
00076 }
00077 else
00078 {
00079 self.nextthink = time + skipover_time;
00080 }
00081 self.frags = 2;
00082 }
00083 else if( self.frags == 2 )
00084 {
00085
00086 do_sound = snap_extnav_osd_check(v_start, (v_start - (self.health/2 * v_right) + (self.health/2 * v_forward) ) );
00087 if( do_sound > 0 )
00088 {
00089 setorigin(self, trace_endpos);
00090 snap_extnav_osd_sound();
00091 self.nextthink = time + cycle_time;
00092 }
00093 else
00094 {
00095 self.nextthink = time + skipover_time;
00096 }
00097 self.frags = 3;
00098 }
00099 else if( self.frags == 3 )
00100 {
00101
00102 do_sound = snap_extnav_osd_check(v_start, (v_start + self.health * v_forward));
00103 if( do_sound > 0 )
00104 {
00105 setorigin(self, trace_endpos);
00106 snap_extnav_osd_sound();
00107 self.nextthink = time + cycle_time;
00108 }
00109 else
00110 {
00111 self.nextthink = time + skipover_time;
00112 }
00113 self.frags = 4;
00114 }
00115 else if( self.frags == 4 )
00116 {
00117
00118 do_sound = snap_extnav_osd_check(v_start, (v_start + (self.health/2 * v_right) + (self.health/2 * v_forward) ) );
00119 if( do_sound > 0 )
00120 {
00121 setorigin(self, trace_endpos);
00122 snap_extnav_osd_sound();
00123 self.nextthink = time + cycle_time;
00124 }
00125 else
00126 {
00127 self.nextthink = time + skipover_time;
00128 }
00129 self.frags = 5;
00130 }
00131 else if( self.frags == 5 )
00132 {
00133
00134 do_sound = snap_extnav_osd_check(v_start, (v_start + self.health * v_right));
00135 if( do_sound > 0 )
00136 {
00137 setorigin(self, trace_endpos);
00138 snap_extnav_osd_sound();
00139 }
00140 self.frags = 0;
00141
00142 remove(self);
00143 }
00144 else
00145 {
00146
00147 local string reentryno;
00148 reentryno = ftos(self.frags);
00149 objerror("OSD: space detection given incorrect reentry point of ", reentryno, ".\nPlease report this bug to the developers and quote the\nreentry point specifed above. Thank you.\n");
00150 }
00151 };
00152
00160 float snap_extnav_osd_check(vector v_start, vector v_off)
00161 {
00162 local float retval;
00163
00164 retval = true;
00165
00166 traceline(v_start, v_off, true, self);
00167 if( trace_fraction != 1 )
00168 retval = false;
00169
00170 return retval;
00171 };
00172
00176 void snap_extnav_osd_sound()
00177 {
00178
00179
00180 if( self.owner.waterlevel > 1)
00181 {
00182
00183
00184
00185 safe_soundtoclient(self.owner, self, CHAN_AUTO, "misc/water2.wav", 1, ATTN_NORM);
00186 }
00187 else
00188 {
00189 safe_soundtoclient(self.owner, self, CHAN_AUTO, "nav/wind.wav", 1, ATTN_NORM);
00190 }
00191 };
00192
00203 void snap_extnav_compass()
00204 {
00205 local float normal_yaw;
00206
00207
00208 normal_yaw = snap_misc_normalyaw(self.angles_y);
00209
00210
00211 if( normal_yaw >= 337.5 )
00212 snap_misc_m2m("North North West.\n");
00213 else if( normal_yaw >= 330 )
00214 snap_misc_m2m("330 degrees.\n");
00215 else if( normal_yaw >= 315 )
00216 snap_misc_m2m("North West.\n");
00217 else if( normal_yaw >= 300 )
00218 snap_misc_m2m("300 degrees.\n");
00219 else if( normal_yaw >= 292.5 )
00220 snap_misc_m2m("West North West.\n");
00221 else if( normal_yaw >= 270 )
00222 snap_misc_m2m("West.\n");
00223 else if( normal_yaw >= 247.5 )
00224 snap_misc_m2m("West South West.\n");
00225 else if( normal_yaw >= 240 )
00226 snap_misc_m2m("240 degrees.\n");
00227 else if( normal_yaw >= 225 )
00228 snap_misc_m2m("South West.\n");
00229 else if( normal_yaw >= 210 )
00230 snap_misc_m2m("210 degrees.\n");
00231 else if( normal_yaw >= 202.5 )
00232 snap_misc_m2m("South South West.\n");
00233 else if( normal_yaw >= 180 )
00234 snap_misc_m2m("South.\n");
00235 else if( normal_yaw >= 157.5 )
00236 snap_misc_m2m("South South East.\n");
00237 else if( normal_yaw >= 150 )
00238 snap_misc_m2m("150 degrees.\n");
00239 else if( normal_yaw >= 135 )
00240 snap_misc_m2m("South East.\n");
00241 else if( normal_yaw >= 120 )
00242 snap_misc_m2m("120 degrees.\n");
00243 else if( normal_yaw >= 112.5 )
00244 snap_misc_m2m("East South East.\n");
00245 else if( normal_yaw >= 90 )
00246 snap_misc_m2m("East.\n");
00247 else if( normal_yaw >= 67.5 )
00248 snap_misc_m2m("East North East.\n");
00249 else if( normal_yaw >= 60 )
00250 snap_misc_m2m("60 degrees.\n");
00251 else if( normal_yaw >= 45 )
00252 snap_misc_m2m("North East.\n");
00253 else if( normal_yaw >= 30 )
00254 snap_misc_m2m("30 degrees.\n");
00255 else if( normal_yaw >= 22.5 )
00256 snap_misc_m2m("North North East.\n");
00257 else if( normal_yaw >= 0 )
00258 snap_misc_m2m("North.\n");
00259 };
00260
00261