agrip/extnav.mqc

Go to the documentation of this file.
00001 /*  Copyright 2005 Matthew Tylee Atkinson
00002 
00003     This program is free software; you can redistribute it and/or modify
00004     it under the terms of the GNU General Public License as published by
00005     the Free Software Foundation; either version 2 of the License, or
00006     (at your option) any later version.
00007 
00008     This program is distributed in the hope that it will be useful,
00009     but WITHOUT ANY WARRANTY; without even the implied warranty of
00010     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011     GNU General Public License for more details.
00012 
00013     You should have received a copy of the GNU General Public License
00014     along with this program; if not, write to the Free Software
00015     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00016 
00017     See file, 'COPYING', for details.
00018 */
00019 
00020 /* $AGRIP-START */
00021 /* AGRIP Extra Navigation functions not depending on the nav object */
00022 
00023 
00024 // CONSTANTS
00025 
00026 // <none>
00027 
00028 
00029 // PROTOTYPES
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 // IMPLEMENTATIONS
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     // Time for each sounder event...
00056     cycle_time = 0.5;
00057     skipover_time = 0;
00058 
00059     // Are we in the middle of a cycle?
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         // Left...
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         // ``NW''
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         // Forward...
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         // ``NE''
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         // Right...
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         // Finished sweep; vanish...
00142         remove(self);
00143     }
00144     else
00145     {
00146         // Error!
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     //local float sndlev;
00179 
00180     if( self.owner.waterlevel > 1)
00181     {
00182         //sndlev = 2 * self.owner.ammo_cells;
00183         //if( sndlev > 1 )
00184         //    sndlev = 1;
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     // Get Normalised yaw...
00208     normal_yaw = snap_misc_normalyaw(self.angles_y);
00209  
00210     // Work out what direction we're pointing in... 
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 /* $AGRIP-END */

Generated on Tue Jan 1 17:55:54 2008 for AudioQuake QuakeC by  doxygen 1.5.4