src/hcode/btech/mech.scan.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sys/file.h>
#include "mech.h"
#include "p.mech.utils.h"
#include "p.mech.los.h"
#include "p.map.obj.h"
#include "p.mech.scan.h"
#include "autopilot.h"
#include "p.autopilot_command.h"
#include "p.mine.h"
#include "p.mech.build.h"
#include "p.mech.status.h"
#include "p.mech.update.h"
#include "p.mech.combat.h"
#include "p.mech.combat.misc.h"

Include dependency graph for mech.scan.c:

Go to the source code of this file.

Defines

#define SHOW_INFO   1
#define SHOW_ARMOR   2
#define SHOW_WEAPONS   4

Functions

void mech_scan (dbref player, void *data, char *buffer)
void mech_report (dbref player, void *data, char *buffer)
void ShowTurretFacing (dbref player, int spaces, MECH *mech)
void PrintReport (dbref player, MECH *mech, MECH *tempMech, float range)
void PrintEnemyStatus (dbref player, MECH *mymech, MECH *mech, float range, int opt)
void mech_bearing (dbref player, void *data, char *buffer)
void mech_range (dbref player, void *data, char *buffer)
void mech_vector (dbref player, void *data, char *buffer)
void PrintEnemyWeaponStatus (MECH *mech, dbref player)
void mech_sight (dbref player, void *data, char *buffer)
void mech_view (dbref player, void *data, char *buffer)


Define Documentation

#define SHOW_ARMOR   2

Definition at line 30 of file mech.scan.c.

Referenced by mech_scan(), and PrintEnemyStatus().

#define SHOW_INFO   1

Definition at line 29 of file mech.scan.c.

Referenced by mech_scan(), and PrintEnemyStatus().

#define SHOW_WEAPONS   4

Definition at line 31 of file mech.scan.c.

Referenced by mech_scan(), and PrintEnemyStatus().


Function Documentation

void mech_bearing ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 466 of file mech.scan.c.

References args, cch, FaMechRange, FindBearing(), FindTargetXY(), getMap(), getMech(), InLineOfSight(), MapCoordToRealCoord(), MECH::mapindex, mech_parseattributes(), MECH_USUAL, MechFX, MechFY, MechTarget, MechX, MechY, and notify.

Referenced by turret_bearing().

00467 {
00468         MECH *mech = (MECH *) data, *tempMech;
00469         MAP *mech_map;
00470         char *args[4];
00471         int argc;
00472         int ix0, iy0;
00473         float x0, y0;
00474         int ix1, iy1;
00475         float x1, y1, z1;
00476         float temp;
00477         char trash[20];
00478         char buff[100];
00479 
00480         x1 = y1 = -1;
00481 
00482         cch(MECH_USUAL);
00483         x0 = MechFX(mech);
00484         y0 = MechFY(mech);
00485         if(mech->mapindex != -1) {
00486                 mech_map = getMap(mech->mapindex);
00487                 argc = mech_parseattributes(buffer, args, 4);
00488                 if(argc == 0) {
00489                         /* Bearing to current target */
00490                         if(MechTarget(mech) != -1) {
00491                                 tempMech = getMech(MechTarget(mech));
00492                                 if(tempMech) {
00493                                         if(!InLineOfSight(mech, tempMech, MechX(tempMech),
00494                                                                           MechY(tempMech), FaMechRange(mech,
00495                                                                                                                                    tempMech)))
00496                                         {
00497                                                 notify(player, "Target is not in line of sight!");
00498                                                 return;
00499                                         }
00500                                 }
00501                         }
00502                         if(!FindTargetXY(mech, &x1, &y1, &z1)) {
00503                                 notify(player, "There is no default target!");
00504                         } else {
00505                                 strcpy(buff, "Bearing to default target is: ");
00506                         }
00507                 } else if(argc == 2) {
00508                         /* Bearing to X, Y */
00509                         ix1 = atoi(args[0]);
00510                         iy1 = atoi(args[1]);
00511                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00512                                  iy1 < mech_map->map_height)) {
00513                                 notify(player, "Invalid map coordinates!");
00514                                 x1 = y1 = -1.;
00515                         } else {
00516                                 sprintf(buff, "Bearing to  %d,%d is: ", ix1, iy1);
00517                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00518                         }
00519                 } else if(argc == 4) {
00520                         ix0 = atoi(args[0]);
00521                         iy0 = atoi(args[1]);
00522                         ix1 = atoi(args[2]);
00523                         iy1 = atoi(args[3]);
00524 
00525                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00526                                  y1 < mech_map->map_height && ix0 >= 0 &&
00527                                  ix0 <= mech_map->map_width && iy0 >= 0 &&
00528                                  iy0 < mech_map->map_height)) {
00529                                 notify(player, "Invalid map coordinates!");
00530                                 x1 = y1 = -1;
00531                         } else {
00532                                 sprintf(buff, "Bearing to %d,%d from %d,%d is: ", ix1, iy1,
00533                                                 ix0, iy0);
00534                                 MapCoordToRealCoord(ix0, iy0, &x0, &y0);
00535                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00536                         }
00537                 } else {
00538                         notify(player,
00539                                    "Invalid number of attributes to Bearing function!");
00540                 }
00541                 if(x1 != -1) {
00542                         temp = FindBearing(x0, y0, x1, y1);
00543                         sprintf(trash, "%.0f degrees.", temp);
00544                         strcat(buff, trash);
00545                         notify(player, buff);
00546                 }
00547         } else {
00548                 notify(player, "You are not on a map!");
00549         }
00550 }

void mech_range ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 552 of file mech.scan.c.

References args, cch, DOCHECK, Elevation, FaMechRange, FindHexRange(), FindRange(), FindTargetXY(), getMap(), getMech(), InLineOfSight(), MapCoordToRealCoord(), MECH::mapindex, MapIsDark, mech_parseattributes(), MECH_USUAL, MechFX, MechFY, MechFZ, MechTarget, MechX, MechY, MechZ, notify, and ZSCALE.

Referenced by turret_range().

00553 {
00554         MECH *mech = (MECH *) data, *tempMech = NULL;
00555         MAP *mech_map;
00556         char *args[4];
00557         int argc;
00558         int ix0, iy0;
00559         float x0, y0, z0;
00560         int ix1, iy1;
00561         float x1, y1, z1, hr;
00562         float temp;
00563         char trash[40];
00564         char buff[100];
00565         char buf1[20];
00566         char buf2[20];
00567 
00568         x1 = y1 = -1;
00569 
00570         cch(MECH_USUAL);
00571         x0 = MechFX(mech);
00572         y0 = MechFY(mech);
00573         z0 = MechFZ(mech);
00574         if(mech->mapindex != -1) {
00575                 mech_map = getMap(mech->mapindex);
00576                 argc = mech_parseattributes(buffer, args, 4);
00577                 if(argc == 0) {
00578                         /* Range to current target */
00579                         if(MechTarget(mech) != -1) {
00580                                 tempMech = getMech(MechTarget(mech));
00581                                 if(tempMech) {
00582                                         if(!InLineOfSight(mech, tempMech, MechX(tempMech),
00583                                                                           MechY(tempMech), FaMechRange(mech,
00584                                                                                                                                    tempMech)))
00585                                         {
00586                                                 notify(player, "Target is not in line of sight!");
00587                                                 return;
00588                                         }
00589                                 }
00590                         }
00591                         DOCHECK(!FindTargetXY(mech, &x1, &y1, &z1),
00592                                         "There is no default target!");
00593                         if(MapIsDark(mech_map) && !tempMech)
00594                                 z1 = ZSCALE * MechZ(mech);
00595                         strcpy(buff, "Range to default target is: ");
00596                 } else if(argc == 2) {
00597                         /* Range to X, Y */
00598                         ix1 = atoi(args[0]);
00599                         iy1 = atoi(args[1]);
00600                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00601                                  iy1 < mech_map->map_height)) {
00602                                 notify(player, "Invalid map coordinates!");
00603                                 x1 = y1 = -1.;
00604                         } else {
00605                                 sprintf(buff, "Range to  %d,%d is: ", ix1, iy1);
00606                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00607                                 if(MapIsDark(mech_map))
00608                                         z1 = ZSCALE * MechZ(mech);
00609                                 else
00610                                         z1 = ZSCALE * Elevation(mech_map, ix1, iy1);
00611                         }
00612                 } else if(argc == 4) {
00613                         /* Range to X, Y from given X, Y */
00614                         ix0 = atoi(args[0]);
00615                         iy0 = atoi(args[1]);
00616                         ix1 = atoi(args[2]);
00617                         iy1 = atoi(args[3]);
00618 
00619                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00620                                  iy1 < mech_map->map_height && ix0 >= 0 &&
00621                                  ix0 <= mech_map->map_width && iy0 >= 0 &&
00622                                  iy0 < mech_map->map_height)) {
00623                                 notify(player, "Invalid map coordinates!");
00624                                 x1 = y1 = -1;
00625                         } else {
00626                                 sprintf(buff, "Range to %d,%d from %d,%d is: ", ix1, iy1,
00627                                                 ix0, iy0);
00628                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00629                                 MapCoordToRealCoord(ix0, iy0, &x0, &y0);
00630                                 if(MapIsDark(mech_map))
00631                                         z1 = z0 = 0;
00632                                 else {
00633                                         z1 = ZSCALE * Elevation(mech_map, ix1, iy1);
00634                                         z0 = ZSCALE * Elevation(mech_map, ix0, iy0);
00635                                 }
00636                         }
00637                 } else {
00638                         notify(player, "Invalid number of attributes to Range function!");
00639                         x1 = y1 = -1;
00640                 }
00641                 if(x1 != -1) {
00642                         temp = FindRange(x0, y0, z0, x1, y1, z1);
00643                         hr = FindHexRange(x0, y0, x1, y1);
00644                         sprintf(buf1, "%.1f", temp);
00645                         sprintf(buf2, "%.1f", hr);
00646                         if(strcmp(buf1, buf2))
00647                                 sprintf(trash, "%s hexes (%s ground hexes).", buf1, buf2);
00648                         else
00649                                 sprintf(trash, "%s hexes.", buf1);
00650                         strcat(buff, trash);
00651                         notify(player, buff);
00652                 }
00653         } else {
00654                 notify(player, "You are not on a map!");
00655         }
00656 }

void mech_report ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 233 of file mech.scan.c.

References args, cch, DOCHECK, Elevation, FaMechRange, find_mech_in_hex(), FindRange(), FindTargetDBREFFromMapNumber(), FindTargetXY(), getMap(), getMech(), InLineOfSight(), InLineOfSight_NB(), MapCoordToRealCoord(), MECH::mapindex, mech_parseattributes(), MECH_USUAL, MechFX, MechFY, MechFZ, MechScanRange, MechTarget, MechX, MechY, numargs, PrintReport(), ValidCoordA, and ZSCALE.

Referenced by turret_report().

00234 {
00235         MECH *mech = (MECH *) data;
00236         MAP *mech_map;
00237         char *args[3];
00238         int mapx = 0, mapy = 0;
00239         char targetID[2];
00240         dbref target;
00241         int numargs;
00242         MECH *tempMech = NULL;
00243         float fx, fy, fz = 0.0;
00244         float range = 0.0, enemyX, enemyY, enemyZ;
00245 
00246         mech_map = getMap(mech->mapindex);
00247         cch(MECH_USUAL);
00248         numargs = mech_parseattributes(buffer, args, 3);
00249         DOCHECK(numargs > 2, "Wrong number of arguments to report!");
00250         DOCHECK(!MechScanRange(mech), "Your system seems to be inoperational.");
00251         switch (numargs) {
00252         case 1:
00253                 /* Scan Target */
00254                 targetID[0] = args[0][0];
00255                 targetID[1] = args[0][1];
00256                 target = FindTargetDBREFFromMapNumber(mech, targetID);
00257                 tempMech = getMech(target);
00258                 DOCHECK(!tempMech, "Target is not in line of sight!");
00259                 range = FaMechRange(mech, tempMech);
00260                 DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech),
00261                                                            MechY(tempMech), range),
00262                                 "Target is not in line of sight!");
00263                 DOCHECK(!InLineOfSight_NB(mech, tempMech, MechX(tempMech),
00264                                                                   MechY(tempMech), range),
00265                                 "That target isn't seen well enough by the scanners for a report!");
00266                 break;
00267         case 2:
00268                 /* report x, y */
00269                 mapx = atoi(args[0]);
00270                 mapy = atoi(args[1]);
00271                 MapCoordToRealCoord(mapx, mapy, &fx, &fy);
00272                 range =
00273                         FindRange(MechFX(mech), MechFY(mech), MechFZ(mech), fx, fy, fz);
00274                 ValidCoordA(mech_map, mapx, mapy,
00275                                         "Those coordinates are out of scanner range.");
00276                 DOCHECK((int) range > MechScanRange(mech),
00277                                 "Those coordinates are out of scanner range.");
00278                 DOCHECK(!InLineOfSight(mech, tempMech, mapx, mapy, range),
00279                                 "Coordinates are not in line of sight!");
00280                 DOCHECK(!InLineOfSight_NB(mech, tempMech, mapx, mapy, range),
00281                                 "That target isn't seen well enough by the scanners for a report!");
00282                 fz = ZSCALE * Elevation(mech_map, mapx, mapy);
00283                 /* look for enemies in that hex... */
00284                 tempMech = find_mech_in_hex(mech, mech_map, mapx, mapy, 1);
00285                 DOCHECK(!tempMech, "No target found.");
00286                 break;
00287         case 0:
00288                 /* report current target... */
00289                 target = MechTarget(mech);
00290                 tempMech = getMech(target);
00291                 if(tempMech) {
00292                         range = FaMechRange(mech, tempMech);
00293                         DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech),
00294                                                                    MechY(tempMech), range),
00295                                         "Target is not in line of sight!");
00296                         DOCHECK(!InLineOfSight_NB(mech, tempMech, MechX(tempMech),
00297                                                                           MechY(tempMech), range),
00298                                         "That target isn't seen well enough by the scanners for a report!");
00299                 } else {
00300                         DOCHECK(!FindTargetXY(mech, &enemyX, &enemyY, &enemyZ),
00301                                         "No default target set!");
00302                         /* look for enemies in that hex... */
00303                         tempMech = find_mech_in_hex(mech, mech_map, mapx, mapy, 1);
00304                         DOCHECK(!tempMech, "You don't see a thing.");
00305                         DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech),
00306                                                                    MechY(tempMech), range),
00307                                         "You don't see a thing.");
00308                 }
00309         }
00310         if(tempMech)
00311                 PrintReport(player, mech, tempMech, range);
00312 }

void mech_scan ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 33 of file mech.scan.c.

References args, auto_reply(), cch, CLASS_MW, DOCHECK, Elevation, FaMechRange, find_mech_in_hex(), FindRange(), FindTargetDBREFFromMapNumber(), FindTargetXY(), getMap(), getMech(), GetMechToMechID(), InLineOfSight(), InLineOfSight_NB(), LOCK_BUILDING, LOCK_HEX, MapCoordToRealCoord(), MECH::mapindex, mech_parseattributes(), mech_printf(), MECH_USUAL, MechFX, MechFY, MechFZ, MechIsObservator, MechScanRange, MECHSTARTED, MechStatus, MechTarget, MechTargX, MechTargY, MechType, MechX, MechY, notify, numargs, PrintEnemyStatus(), SHOW_ARMOR, show_building_in_hex(), SHOW_INFO, show_mines_in_hex(), SHOW_WEAPONS, tprintf(), ValidCoordA, and ZSCALE.

Referenced by turret_scan().

00034 {
00035         MECH *mech = (MECH *) data;
00036         MAP *mech_map;
00037         char *args[4];
00038         int mapx = 0, mapy = 0;
00039         char targetID[2];
00040         dbref target;
00041         int numargs;
00042         MECH *tempMech = NULL;
00043         float fx, fy, fz = 0.0;
00044         float range = 0.0, enemyX, enemyY, enemyZ;
00045         int dob = 0, doh = 0;
00046         int options = SHOW_INFO | SHOW_ARMOR | SHOW_WEAPONS;
00047 
00048         mech_map = getMap(mech->mapindex);
00049         cch(MECH_USUAL);
00050         numargs = mech_parseattributes(buffer, args, 4);
00051         DOCHECK(numargs > 3, "Wrong number of arguments to scan!");
00052         DOCHECK(!MechScanRange(mech), "Your system seems to be inoperational.");
00053         switch (numargs) {
00054         case 1:
00055                 /* Scan Target */
00056                 targetID[0] = args[0][0];
00057                 if(args[0][1]) {
00058                         targetID[1] = args[0][1];
00059                         target = FindTargetDBREFFromMapNumber(mech, targetID);
00060                         tempMech = getMech(target);
00061                         DOCHECK(!tempMech, "Target is not in line of sight!");
00062                         range = FaMechRange(mech, tempMech);
00063                         DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech),
00064                                                                    MechY(tempMech), range),
00065                                         "Target is not in line of sight!");
00066                         DOCHECK(!InLineOfSight_NB(mech, tempMech, MechX(tempMech),
00067                                                                           MechY(tempMech), range),
00068                                         "That target isn't seen well enough by the scanners for scanning!");
00069                         DOCHECK(!MechIsObservator(mech) &&
00070                                         (int) range > MechScanRange(mech),
00071                                         "Target is out of scanner range.");
00072                         break;
00073                 } else {                                /* Default target */
00074                         switch (toupper(args[0][0])) {
00075                         case 'A':
00076                                 options = SHOW_ARMOR;
00077                                 break;
00078                         case 'I':
00079                                 options = SHOW_INFO;
00080                                 break;
00081                         case 'W':
00082                                 options = SHOW_WEAPONS;
00083                                 break;
00084                         default:
00085                                 notify(player, "Truly odd option!");
00086                                 return;
00087                         }
00088                 }
00089         case 0:
00090                 /* scan current target... */
00091                 target = MechTarget(mech);
00092                 tempMech = getMech(target);
00093                 if(tempMech) {
00094                         range = FaMechRange(mech, tempMech);
00095                         DOCHECK(!MechIsObservator(mech) &&
00096                                         (int) range > MechScanRange(mech),
00097                                         "Target is out of scanner range.");
00098                         DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech),
00099                                                                    MechY(tempMech), range),
00100                                         "Target is not in line of sight!");
00101                         DOCHECK(!InLineOfSight_NB(mech, tempMech, MechX(tempMech),
00102                                                                           MechY(tempMech), range),
00103                                         "That target isn't seen well enough by the scanners for scanning!");
00104                 } else {
00105                         if(!(MechStatus(mech) & LOCK_BUILDING))
00106                                 DOCHECK(!FindTargetXY(mech, &enemyX, &enemyY, &enemyZ),
00107                                                 "No default target set!");
00108                         mapx = MechTargX(mech);
00109                         mapy = MechTargY(mech);
00110                         MapCoordToRealCoord(mapx, mapy, &fx, &fy);
00111                         fz = ZSCALE * Elevation(mech_map, mapx, mapy);
00112                         range =
00113                                 FindRange(MechFX(mech), MechFY(mech), MechFZ(mech), fx, fy,
00114                                                   fz);
00115                         ValidCoordA(mech_map, mapx, mapy,
00116                                                 "Those coordinates are out of scanner range.");
00117                         DOCHECK(!MechIsObservator(mech) &&
00118                                         (int) range > MechScanRange(mech),
00119                                         "Those coordinates are out of scanner range.");
00120                         DOCHECK(!InLineOfSight_NB(mech, tempMech, mapx, mapy, range),
00121                                         "Target hex is not in line of sight!");
00122                         /* look for enemies in that hex... */
00123                         if(MechStatus(mech) & LOCK_BUILDING)
00124                                 dob = 1;
00125                         else if(MechStatus(mech) & LOCK_HEX) {
00126                                 dob = 1;
00127                                 doh = 1;
00128                         } else if(!(tempMech =
00129                                                 find_mech_in_hex(mech, mech_map, mapx, mapy, 1)))
00130                                 tempMech = (MECH *) NULL;
00131                 }
00132                 break;
00133         case 3:
00134                 /* scan x, y b */
00135                 mapx = atoi(args[0]);
00136                 mapy = atoi(args[1]);
00137                 ValidCoordA(mech_map, mapx, mapy,
00138                                         "Those coordinates are out of scanner range.");
00139                 switch (toupper(args[2][0])) {
00140                 case 'H':
00141                         doh = 1;
00142                 case 'B':
00143                         dob = 1;
00144                         break;
00145                 default:
00146                         notify(player, "Invalid 3rd argument!");
00147                         return;
00148                 }
00149                 MapCoordToRealCoord(mapx, mapy, &fx, &fy);
00150                 fz = ZSCALE * Elevation(mech_map, mapx, mapy);
00151                 range =
00152                         FindRange(MechFX(mech), MechFY(mech), MechFZ(mech), fx, fy, fz);
00153                 DOCHECK((int) range > MechScanRange(mech),
00154                                 "Those coordinates are out of scanner range.");
00155                 DOCHECK(!InLineOfSight(mech, tempMech, mapx, mapy, range),
00156                                 "Coordinates are not in line of sight!");
00157                 break;
00158         case 2:
00159                 /* scan x, y */
00160                 mapx = atoi(args[0]);
00161                 mapy = atoi(args[1]);
00162                 if(!mapx && strcmp(args[0], "0")) {
00163                         targetID[0] = args[0][0];
00164                         targetID[1] = args[0][1];
00165                         target = FindTargetDBREFFromMapNumber(mech, targetID);
00166                         tempMech = getMech(target);
00167                         DOCHECK(!tempMech, "Target is not in line of sight!");
00168                         range = FaMechRange(mech, tempMech);
00169                         DOCHECK(!InLineOfSight(mech, tempMech, MechX(tempMech),
00170                                                                    MechY(tempMech), range),
00171                                         "Target is not in line of sight!");
00172                         DOCHECK(!MechIsObservator(mech) &&
00173                                         (int) range > MechScanRange(mech),
00174                                         "Target is out of scanner range.");
00175                         switch (toupper(args[1][0])) {
00176                         case 'A':
00177                                 options = SHOW_ARMOR;
00178                                 break;
00179                         case 'I':
00180                                 options = SHOW_INFO;
00181                                 break;
00182                         case 'W':
00183                                 options = SHOW_WEAPONS;
00184                                 break;
00185                         default:
00186                                 notify(player, "Truly odd option!");
00187                                 return;
00188                         }
00189                         break;
00190                 }
00191                 ValidCoordA(mech_map, mapx, mapy,
00192                                         "Those coordinates are out of scanner range.");
00193                 MapCoordToRealCoord(mapx, mapy, &fx, &fy);
00194                 range =
00195                         FindRange(MechFX(mech), MechFY(mech), MechFZ(mech), fx, fy, fz);
00196                 DOCHECK(!MechIsObservator(mech) &&
00197                                 (int) range > MechScanRange(mech),
00198                                 "Those coordinates are out of scanner range.");
00199                 DOCHECK(!InLineOfSight(mech, tempMech, mapx, mapy, range),
00200                                 "Coordinates are not in line of sight!");
00201                 fz = ZSCALE * Elevation(mech_map, mapx, mapy);
00202                 /* look for enemies in that hex... */
00203                 if(!(tempMech = find_mech_in_hex(mech, mech_map, mapx, mapy, 1)))
00204                         tempMech = (MECH *) NULL;
00205                 break;
00206         }
00207         if(tempMech) {
00208                 DOCHECK(!InLineOfSight_NB(mech, tempMech, MechX(tempMech),
00209                                                                   MechY(tempMech), range),
00210                                 "That target isn't seen well enough by the scanners for report!");
00211                 DOCHECK((MechType(tempMech) == CLASS_MW),
00212                                 "Your scanners cannot give you precise information on targets that small!");
00213                 PrintEnemyStatus(player, mech, tempMech, range, options);
00214                 if(!MechIsObservator(mech)) {
00215                         mech_printf(tempMech, MECHSTARTED,
00216                                                 "You are being scanned by %s",
00217                                                 GetMechToMechID(tempMech, mech));
00218                         auto_reply(tempMech, tprintf("%s just scanned me.",
00219                                                                                  GetMechToMechID(tempMech, mech)));
00220                 }
00221                 return;
00222         }
00223         if(!dob && !doh) {
00224                 notify(player, "You see nobody in the hex!");
00225                 return;
00226         }
00227         if(dob)
00228                 show_building_in_hex(mech, mapx, mapy);
00229         if(doh)
00230                 show_mines_in_hex(player, mech, range, mapx, mapy);
00231 }

void mech_sight ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 855 of file mech.scan.c.

References args, cch, FireWeaponNumber(), getMap(), MECH::mapindex, mech_parseattributes(), MECH_USUAL, and notify.

Referenced by turret_sight().

00856 {
00857         MECH *mech = (MECH *) data;
00858         MAP *mech_map;
00859         char *args[5];
00860         int argc;
00861         int weapnum;
00862 
00863         mech_map = getMap(mech->mapindex);
00864         cch(MECH_USUAL);
00865         argc = mech_parseattributes(buffer, args, 5);
00866         if(argc >= 1) {
00867                 weapnum = atoi(args[0]);
00868                 FireWeaponNumber(player, mech, mech_map, weapnum, argc, args, 1);
00869         } else {
00870                 notify(player, "Not enough arguments to the function");
00871         }
00872 }

void mech_vector ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 658 of file mech.scan.c.

References args, cch, DOCHECK, Elevation, FaMechRange, FindBearing(), FindHexRange(), FindRange(), FindTargetXY(), FindZBearing(), getMap(), getMech(), InLineOfSight(), MapCoordToRealCoord(), MECH::mapindex, mech_parseattributes(), MECH_USUAL, MechFX, MechFY, MechFZ, MechTarget, MechX, MechY, notify, and ZSCALE.

00659 {
00660         MECH *mech = (MECH *) data, *tempMech;
00661         MAP *mech_map;
00662         char *args[6];
00663         int argc;
00664         int ix0, iy0, iz0;
00665         float x0, y0, z0;
00666         int ix1, iy1, iz1;
00667         float x1, y1, z1, hr;
00668         float temp;
00669         char trash[40];
00670         char buff[100];
00671         char buf1[20];
00672         char buf2[20];
00673 
00674         x1 = y1 = -1;
00675 
00676         cch(MECH_USUAL);
00677         x0 = MechFX(mech);
00678         y0 = MechFY(mech);
00679         z0 = MechFZ(mech);
00680         if(mech->mapindex != -1) {
00681                 mech_map = getMap(mech->mapindex);
00682                 argc = mech_parseattributes(buffer, args, 6);
00683                 if(argc == 0) {
00684                         /* Range to current target */
00685                         if(MechTarget(mech) != -1) {
00686                                 tempMech = getMech(MechTarget(mech));
00687                                 if(tempMech) {
00688                                         if(!InLineOfSight(mech, tempMech, MechX(tempMech),
00689                                                                           MechY(tempMech), FaMechRange(mech,
00690                                                                                                                                    tempMech)))
00691                                         {
00692                                                 notify(player, "Target is not in line of sight!");
00693                                                 return;
00694                                         }
00695                                 }
00696                         }
00697                         DOCHECK(!FindTargetXY(mech, &x1, &y1, &z1),
00698                                         "There is no default target!");
00699                         strcpy(buff, "Vector to default target is: ");
00700                 } else if(argc == 2) {
00701                         /* Range to X, Y */
00702                         ix1 = atoi(args[0]);
00703                         iy1 = atoi(args[1]);
00704                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00705                                  iy1 < mech_map->map_height)) {
00706                                 notify(player, "Invalid map coordinates!");
00707                                 x1 = y1 = -1.;
00708                         } else {
00709                                 sprintf(buff, "Vector to  %d,%d is: ", ix1, iy1);
00710                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00711                                 z1 = ZSCALE * Elevation(mech_map, ix1, iy1);
00712                         }
00713                 } else if(argc == 3) {
00714                         iz0 = z0 / ZSCALE;
00715                         ix1 = atoi(args[0]);
00716                         iy1 = atoi(args[1]);
00717                         iz1 = atoi(args[2]);
00718                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00719                                  iy1 < mech_map->map_height)) {
00720                                 notify(player, "Invalid map coordinates!");
00721                                 x1 = y1 = -1.;
00722                         } else {
00723                                 sprintf(buff, "Vector to  %d,%d,%d is: ", ix1, iy1, iz1);
00724                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00725                                 z1 = ZSCALE * iz1;
00726                         }
00727                 } else if(argc == 4) {
00728                         /* Range to X, Y from given X, Y */
00729                         ix0 = atoi(args[0]);
00730                         iy0 = atoi(args[1]);
00731                         ix1 = atoi(args[2]);
00732                         iy1 = atoi(args[3]);
00733 
00734                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00735                                  y1 < mech_map->map_height && ix0 >= 0 &&
00736                                  ix0 <= mech_map->map_width && iy0 >= 0 &&
00737                                  iy0 < mech_map->map_height)) {
00738                                 notify(player, "Invalid map coordinates!");
00739                                 x1 = y1 = -1;
00740                         } else {
00741                                 sprintf(buff, "Vector to %d,%d from %d,%d is: ", ix1, iy1,
00742                                                 ix0, iy0);
00743                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00744                                 MapCoordToRealCoord(ix0, iy0, &x0, &y0);
00745                                 z1 = ZSCALE * Elevation(mech_map, ix1, iy1);
00746                                 z0 = ZSCALE * Elevation(mech_map, ix0, iy0);
00747                         }
00748                 } else if(argc == 6) {
00749                         ix0 = atoi(args[0]);
00750                         iy0 = atoi(args[1]);
00751                         iz0 = atoi(args[2]);
00752                         ix1 = atoi(args[3]);
00753                         iy1 = atoi(args[4]);
00754                         iz1 = atoi(args[5]);
00755 
00756                         if(!(ix1 >= 0 && ix1 < mech_map->map_width && iy1 >= 0 &&
00757                                  y1 < mech_map->map_height && ix0 >= 0 &&
00758                                  ix0 <= mech_map->map_width && iy0 >= 0 &&
00759                                  iy0 < mech_map->map_height)) {
00760                                 notify(player, "Invalid map coordinates!");
00761                                 x1 = y1 = -1;
00762                         } else {
00763                                 sprintf(buff, "Vector to %d,%d,%d from %d,%d,%d is: ", ix1,
00764                                                 iy1, iz1, ix0, iy0, iz0);
00765                                 MapCoordToRealCoord(ix1, iy1, &x1, &y1);
00766                                 MapCoordToRealCoord(ix0, iy0, &x0, &y0);
00767                                 z1 = ZSCALE * iz1;
00768                                 z0 = ZSCALE * iz0;
00769                         }
00770 
00771                 } else {
00772                         notify(player,
00773                                    "Invalid number of attributes to Vector function!");
00774                         x1 = y1 = -1;
00775                 }
00776                 if(x1 != -1) {
00777                         /* range */
00778                         temp = FindRange(x0, y0, z0, x1, y1, z1);
00779                         hr = FindHexRange(x0, y0, x1, y1);
00780                         sprintf(buf1, "%.1f", temp);
00781                         sprintf(buf2, "%.1f", hr);
00782                         if(strcmp(buf1, buf2))
00783                                 sprintf(trash, "%s hexes (%s ground hexes) and ", buf1, buf2);
00784                         else
00785                                 sprintf(trash, "%s hexes and ", buf1);
00786                         strcat(buff, trash);
00787 
00788                         /* bearing */
00789                         temp = FindBearing(x0, y0, x1, y1);
00790                         if(argc != 0 && argc != 3 && argc != 6)
00791                                 sprintf(trash, "%.0f degrees.", temp);
00792                         else
00793                                 sprintf(trash, "%.0f degrees mark %c%d.", temp,
00794                                                 (z1 > z0 ? '+' : z1 < z0 ? '-' : ' '),
00795                                                 FindZBearing(x0, y0, z0, x1, y1, z1));
00796                         strcat(buff, trash);
00797 
00798                         notify(player, buff);
00799                 }
00800         } else {
00801                 notify(player, "You are not on a map!");
00802         }
00803 }

void mech_view ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 874 of file mech.scan.c.

References A_MECHDESC, args, cch, DOCHECK, FindTargetDBREFFromMapNumber(), FlMechRange, getMap(), getMech(), InLineOfSight(), InLineOfSight_NB(), MECH::mapindex, mech_notify(), mech_parseattributes(), MECH_USUAL, MECHALL, MECHPILOT, MechTarget, MechX, MechY, notify, and silly_atr_get().

00875 {
00876         MECH *mech = (MECH *) data, *target;
00877         MAP *mech_map;
00878         int targetnum;
00879         char targetID[5];
00880         char *args[5];
00881         int argc;
00882         char *target_desc;
00883 
00884         cch(MECH_USUAL);
00885         argc = mech_parseattributes(buffer, args, 2);
00886         if(argc == 0) {                         /* default target */
00887                 if(MechTarget(mech) == -1) {
00888                         mech_notify(mech, MECHALL,
00889                                                 "You do not have a default target set!");
00890                         return;
00891                 }
00892                 target = getMech(MechTarget(mech));
00893                 if(!target) {
00894                         mech_notify(mech, MECHALL, "Invalid default target!");
00895                         MechTarget(mech) = -1;
00896                         return;
00897                 }
00898                 DOCHECK(!InLineOfSight_NB(mech, target, MechX(target),
00899                                                                   MechY(target), FlMechRange(mech_map, mech,
00900                                                                                                                          target)),
00901                                 "That target isn't seen well enough by the scannfers for viewing!");
00902                 if(*(target_desc = silly_atr_get(target->mynum, A_MECHDESC)))
00903                         notify(player, target_desc);
00904                 else
00905                         notify(player, "That target has no markings.");
00906         } else if(argc == 1) {          /* ID number */
00907                 targetID[0] = args[0][0];
00908                 targetID[1] = args[0][1];
00909                 targetnum = FindTargetDBREFFromMapNumber(mech, targetID);
00910                 if(targetnum == -1) {
00911                         mech_notify(mech, MECHPILOT, "Target is not in line of sight!");
00912                         return;
00913                 }
00914                 target = getMech(targetnum);
00915                 mech_map = getMap(mech->mapindex);
00916 
00917                 if(!target ||
00918                    !InLineOfSight(mech, target, MechX(target), MechY(target),
00919                                                   FlMechRange(mech_map, mech, target))) {
00920                         mech_notify(mech, MECHPILOT, "Target is not in line of sight!");
00921                         return;
00922                 }
00923 
00924                 DOCHECK(!InLineOfSight_NB(mech, target, MechX(target),
00925                                                                   MechY(target), FlMechRange(mech_map, mech,
00926                                                                                                                          target)),
00927                                 "That target isn't seen well enough by the scanners for viewing!");
00928 
00929                 if(*(target_desc = silly_atr_get(target->mynum, A_MECHDESC)))
00930                         notify(player, target_desc);
00931                 else
00932                         notify(player, "That target has no markings.");
00933         } else
00934                 notify(player, "Invalid number of arguments to function.");
00935 }

void PrintEnemyStatus ( dbref  player,
MECH mymech,
MECH mech,
float  range,
int  opt 
)

Definition at line 434 of file mech.scan.c.

References CheckData(), getMech(), GetMechToMechID(), MechCarrying, MechCritStatus, MechStatus, notify, notify_printf(), OBSERVATORIC, PrintArmorStatus(), PrintEnemyWeaponStatus(), PrintReport(), PrintWeaponStatus(), SHOW_ARMOR, SHOW_INFO, SHOW_WEAPONS, TORSO_LEFT, and TORSO_RIGHT.

Referenced by mech_scan().

00436 {
00437         MECH *tempMech;
00438         int owner = 0;
00439 
00440         if(!CheckData(player, mech))
00441                 return;
00442         if(MechCritStatus(mymech) & OBSERVATORIC)
00443                 owner = 1;
00444         PrintReport(player, mymech, mech, range);
00445         if(opt & SHOW_ARMOR)
00446                 PrintArmorStatus(player, mech, owner);
00447         if(opt & SHOW_INFO) {
00448                 if(MechStatus(mech) & TORSO_RIGHT)
00449                         notify(player, "Torso is 60 degrees right");
00450                 if(MechStatus(mech) & TORSO_LEFT)
00451                         notify(player, "Torso is 60 degrees left");
00452                 if(MechCarrying(mech) > 0)
00453                         if((tempMech = getMech(MechCarrying(mech))))
00454                                 notify_printf(player, "Towing %s.", GetMechToMechID(mech,
00455                                                                                                                                         tempMech));
00456                 notify(player, " ");
00457         }
00458         if(opt & SHOW_WEAPONS) {
00459                 if(owner)
00460                         PrintWeaponStatus(mech, player);
00461                 else
00462                         PrintEnemyWeaponStatus(mech, player);
00463         }
00464 }

void PrintEnemyWeaponStatus ( MECH mech,
dbref  player 
)

Definition at line 805 of file mech.scan.c.

References ArmorStringFromIndex(), CLASS_BSUIT, FindWeapons, MAX_WEAPS_SECTION, MechMove, MechType, MechWeapons, name, notify, NUM_SECTIONS, PartIsNonfunctional, recycle_weaponry(), and SectIsDestroyed.

Referenced by PrintEnemyStatus().

00806 {
00807         unsigned char weaparray[MAX_WEAPS_SECTION];
00808         unsigned char weapdata[MAX_WEAPS_SECTION];
00809         int critical[MAX_WEAPS_SECTION];
00810         int count;
00811         int loop;
00812         int ii;
00813         char weapbuff[70];
00814         char tempbuff[50];
00815         char location[20];
00816         int running_sum = 0;
00817 
00818         recycle_weaponry(mech);
00819         notify(player, "================WEAPON SYSTEMS================");
00820         if(MechType(mech) == CLASS_BSUIT)
00821                 notify(player, "----- Weapon ------ [##]  Holder ------ Status");
00822         else
00823                 notify(player, "----- Weapon ------ [##]  Location ---- Status");
00824         for(loop = 0; loop < NUM_SECTIONS; loop++) {
00825                 if(SectIsDestroyed(mech, loop))
00826                         continue;
00827                 count = FindWeapons(mech, loop, weaparray, weapdata, critical);
00828                 if(count > 0) {
00829                         ArmorStringFromIndex(loop, tempbuff, MechType(mech),
00830                                                                  MechMove(mech));
00831                         sprintf(location, "%-14.14s", tempbuff);
00832 
00833                         for(ii = 0; ii < count; ii++) {
00834                                 sprintf(weapbuff, " %-18.18s [%2d]  ",
00835                                                 &MechWeapons[weaparray[ii]].name[3],
00836                                                 running_sum + ii);
00837                                 strcat(weapbuff, location);
00838 
00839                                 if(PartIsNonfunctional(mech, loop, critical[ii])) {
00840                                         strcat(weapbuff, "%ch%cx*****%c");
00841                                 } else {
00842                                         if(weapdata[ii]) {
00843                                                 strcat(weapbuff, "-----");
00844                                         } else {
00845                                                 strcat(weapbuff, "%cgReady%c");
00846                                         }
00847                                 }
00848                                 notify(player, weapbuff);
00849                         }
00850                         running_sum += count;
00851                 }
00852         }
00853 }

void PrintReport ( dbref  player,
MECH mech,
MECH tempMech,
float  range 
)

Definition at line 337 of file mech.scan.c.

References A_MECHNAME, CLASS_AERO, CLASS_BSUIT, CLASS_MECH, CLASS_MW, FindBearing(), FlyingT, GetArcID(), InWeaponArc(), Jumping, LateralDesc(), Mech_ShowFlags(), MechFX, MechFY, MechHeat, MechIDS(), MechJumpHeading, MechLateral, MechMove, MechSeemsFriend, MechSpeed, MechTons, MechType, MechVerticalSpeed, MechVFacing, MechX, MechY, MechZ, MOVE_BIPED, MOVE_FLY, MOVE_FOIL, MOVE_HOVER, MOVE_HULL, MOVE_NONE, MOVE_QUAD, MOVE_SUB, MOVE_TRACK, MOVE_VTOL, MOVE_WHEEL, MECH::mynum, notify, notify_printf(), ShowTurretFacing(), silly_atr_get(), and TURRETARC.

Referenced by mech_report(), and PrintEnemyStatus().

00338 {
00339         int bearing;
00340         char buff[100];
00341         int weaponarc;
00342         char *mech_name;
00343 
00344         mech_name = silly_atr_get(tempMech->mynum, A_MECHNAME);
00345         sprintf(buff, "[%s]  %-25.25s Tonnage: %d", MechIDS(tempMech,
00346                                                                                                                 MechSeemsFriend(mech,
00347                                                                                                                                                 tempMech)),
00348                         mech_name, MechTons(tempMech));
00349         notify(player, buff);
00350         bearing =
00351                 FindBearing(MechFX(mech), MechFY(mech), MechFX(tempMech),
00352                                         MechFY(tempMech));
00353         sprintf(buff, "      Range: %.1f hex\t\tBearing: %d degrees", range,
00354                         bearing);
00355         notify(player, buff);
00356         sprintf(buff, "      Speed: %.1f KPH\t\tHeading: %d degrees",
00357                         MechSpeed(tempMech), MechVFacing(tempMech));
00358         notify(player, buff);
00359         if(FlyingT(tempMech))
00360                 notify_printf(player, "      Vertical speed: %.1f KPH",
00361                                           MechVerticalSpeed(tempMech));
00362         sprintf(buff, "      X, Y, Z: %3d, %3d, %3d\tHeat: %.0f deg C.",
00363                         MechX(tempMech), MechY(tempMech), MechZ(tempMech),
00364                         10. * MechHeat(tempMech));
00365         notify(player, buff);
00366         if(MechLateral(tempMech))
00367                 notify_printf(player, "      Mech is moving laterally %s",
00368                                           LateralDesc(tempMech));
00369         ShowTurretFacing(player, 6, tempMech);
00370 
00371         switch (MechMove(tempMech)) {
00372         case MOVE_NONE:
00373                 notify(player, "      Type: INSTALLATION");
00374                 break;
00375         case MOVE_BIPED:
00376                 switch (MechType(tempMech)) {
00377                 case CLASS_MW:
00378                         notify(player, "      Type: MECHWARRIOR         Movement: BIPED");
00379                         break;
00380                 case CLASS_MECH:
00381                         notify(player, "      Type: MECH                Movement: BIPED");
00382                         break;
00383                 case CLASS_BSUIT:
00384                         notify(player, "      Type: BATTLESUIT(S)       Movement: BIPED");
00385 
00386                 }
00387                 break;
00388         case MOVE_QUAD:
00389                 notify(player, "      Type: MECH                Movement: QUAD");
00390                 break;
00391         case MOVE_TRACK:
00392                 notify(player, "      Type: VEHICLE             Movement: TRACKED");
00393                 break;
00394         case MOVE_WHEEL:
00395                 notify(player, "      Type: VEHICLE             Movement: WHEELED");
00396                 break;
00397         case MOVE_HOVER:
00398                 notify(player, "      Type: VEHICLE             Movement: HOVER");
00399                 break;
00400         case MOVE_VTOL:
00401                 notify(player, "      Type: VTOL                Movement: VTOL");
00402                 break;
00403         case MOVE_FLY:
00404                 notify_printf(player,
00405                                           "      Type: %-9s             Movement: FLIGHT",
00406                                           MechType(tempMech) ==
00407                                           CLASS_AERO ? "AEROSPACE" : "DROPSHIP");
00408                 break;
00409         case MOVE_HULL:
00410                 notify(player, "      Type: NAVAL               Movement: HULL");
00411                 break;
00412         case MOVE_SUB:
00413                 notify(player, "      Type: NAVAL               Movement: SUBMARINE");
00414                 break;
00415         case MOVE_FOIL:
00416                 notify(player, "      Type: NAVAL               Movement: HYDROFOIL");
00417                 break;
00418         }
00419 
00420         weaponarc = InWeaponArc(mech, MechFX(tempMech), MechFY(tempMech));
00421         if(weaponarc & TURRETARC) {
00422                 notify(player, "      In Turret Arc");
00423                 weaponarc &= ~TURRETARC;
00424         }
00425         notify_printf(player, "      In %s Weapons Arc",
00426                                   GetArcID(mech, weaponarc));
00427         Mech_ShowFlags(player, tempMech, 6, 1);
00428         if(Jumping(tempMech))
00429                 notify_printf(player, "      Mech is Jumping!\tJump Heading: %d",
00430                                           MechJumpHeading(tempMech));
00431         notify(player, " ");
00432 }

void ShowTurretFacing ( dbref  player,
int  spaces,
MECH mech 
)

Definition at line 314 of file mech.scan.c.

References AcceptableDegree(), CLASS_BSUIT, CLASS_MECH, CLASS_MW, GetSectInt, is_aero, MBUF_SIZE, MechFacing, MechMove, MechTurretFacing, MechType, MOVE_NONE, notify, tprintf(), and TURRET.

Referenced by PrintInfoStatus(), and PrintReport().

00315 {
00316         int i;
00317         int j;
00318         char buff[MBUF_SIZE];
00319 
00320         if(GetSectInt(mech, TURRET) && !(MechType(mech) == CLASS_MECH ||
00321                                                                          MechType(mech) == CLASS_BSUIT
00322                                                                          || MechType(mech) == CLASS_MW)
00323            && !is_aero(mech)) {
00324                 i = AcceptableDegree(MechTurretFacing(mech));
00325                 if(i > 180)
00326                         i -= 360;
00327                 j = AcceptableDegree(MechTurretFacing(mech) + MechFacing(mech));
00328                 if(MechMove(mech) != MOVE_NONE)
00329                         sprintf(buff, "      Turret Facing: %d degrees%s", j,
00330                                         i ? tprintf(" (%d offset from heading)", i) : "");
00331                 else
00332                         sprintf(buff, "      Turret Facing: %d degrees", j);
00333                 notify(player, buff);
00334         }
00335 }


Generated on Mon May 28 04:25:37 2007 for BattletechMUX by  doxygen 1.4.7