#include <math.h>
#include "mech.h"
#include "autopilot.h"
#include "spath.h"
#include "mech.notify.h"
#include "p.mech.utils.h"
#include "p.mech.sensor.h"
#include "p.mech.los.h"
#include "p.mech.startup.h"
#include "p.mech.maps.h"
#include "p.ds.bay.h"
#include "p.bsuit.h"
#include "p.glue.h"
Include dependency graph for autopilot_radio.c:
Go to the source code of this file.
Defines | |
#define | Clear(a) |
#define | BACMD(name) char * name (AUTO *autopilot, MECH *mech, char **args, int argc, int chn) |
#define | ACMD(name) static BACMD(name) |
Functions | |
void | sendchannelstuff (MECH *mech, int freq, char *msg) |
void | auto_radio_command_autogun (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_chasetarg (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_dfollow (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_dgoto (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_dropoff (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_embark (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_enterbase (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_follow (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_goto (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_heading (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_help (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_hide (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_jumpjet (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_leavebase (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_ogoto (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_pickup (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_position (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_prone (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_report (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_reset (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_sensor (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_shutdown (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_speed (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_stand (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_startup (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_stop (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_sweight (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_radio_command_target (AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) |
void | auto_reply_event (MUXEVENT *muxevent) |
void | auto_reply (MECH *mech, char *buf) |
void | auto_parse_command (AUTO *autopilot, MECH *mech, int chn, char *buffer) |
Variables | |
struct { | |
char * sho | |
char * name | |
int args | |
int silent | |
void(* fun )(AUTO *autopilot, MECH *mech, char **args, int argc, char *mesg) | |
} | auto_cmds [] |
Definition at line 50 of file autopilot_radio.c.
Definition at line 49 of file autopilot_radio.c.
#define Clear | ( | a | ) |
Value:
auto_disengage(a->mynum, a, ""); \ auto_delcommand(a->mynum, a, "-1"); \ if (a->target >= -1) { \ if (AssignedTarget(a) && a->target != -1) { \ snprintf(buffer, SBUF_SIZE, "autogun target %d", a->target); \ } else { \ snprintf(buffer, SBUF_SIZE, "autogun on"); \ } \ auto_addcommand(a->mynum, autopilot, buffer); \ } \
Definition at line 37 of file autopilot_radio.c.
Referenced by auto_radio_command_dfollow(), auto_radio_command_dgoto(), auto_radio_command_dropoff(), auto_radio_command_embark(), auto_radio_command_enterbase(), auto_radio_command_follow(), auto_radio_command_goto(), auto_radio_command_heading(), auto_radio_command_leavebase(), auto_radio_command_ogoto(), auto_radio_command_pickup(), and auto_radio_command_stop().
Definition at line 1232 of file autopilot_radio.c.
References args, auto_cmds, auto_reply(), AUTOPILOT_MAX_ARGS, Destroyed, LBUF_SIZE, MechID, name, Number, proper_explodearguments(), sho, and silent.
Referenced by sendchannelstuff().
01233 { 01234 01235 int argc, cmd; 01236 char *args[2]; 01237 char *command_args[AUTOPILOT_MAX_ARGS]; 01238 char mech_id[3]; 01239 char message[LBUF_SIZE]; 01240 char reply[LBUF_SIZE]; 01241 int i; 01242 01243 /* Basic checks */ 01244 if(!autopilot || !mech) 01245 return; 01246 if(Destroyed(mech)) 01247 return; 01248 01249 /* Get the args - just need the first one */ 01250 if(proper_explodearguments(buffer, args, 2) < 2) { 01251 /* free args */ 01252 for(i = 0; i < 2; i++) { 01253 if(args[i]) 01254 free(args[i]); 01255 } 01256 return; 01257 } 01258 01259 /* Check to see if the command was given to this AI */ 01260 if(strcmp(args[0], "all")) { 01261 mech_id[0] = MechID(mech)[0]; 01262 mech_id[1] = MechID(mech)[1]; 01263 mech_id[2] = '\0'; 01264 01265 if(strcasecmp(mech_id, args[0])) { 01266 /* free args */ 01267 for(i = 0; i < 2; i++) { 01268 if(args[i]) 01269 free(args[i]); 01270 } 01271 return; 01272 } 01273 01274 } 01275 01276 /* Parse the command */ 01277 cmd = -1; 01278 argc = proper_explodearguments(args[1], command_args, AUTOPILOT_MAX_ARGS); 01279 01280 /* Loop through the various possible commands looking for ours */ 01281 for(i = 0; auto_cmds[i].sho; i++) { 01282 if(!strncmp 01283 (auto_cmds[i].sho, command_args[0], strlen(auto_cmds[i].sho))) 01284 if(!strncmp 01285 (auto_cmds[i].name, command_args[0], 01286 strlen(command_args[0]))) { 01287 if(argc == (auto_cmds[i].args + 1)) { 01288 cmd = i; 01289 break; 01290 } 01291 } 01292 } 01293 01294 /* Did we find a command */ 01295 if(cmd < 0) { 01296 01297 snprintf(message, LBUF_SIZE, "Unable to comprehend the command."); 01298 auto_reply(mech, message); 01299 01300 /* free args */ 01301 for(i = 0; i < 2; i++) { 01302 if(args[i]) 01303 free(args[i]); 01304 } 01305 for(i = 0; i < AUTOPILOT_MAX_ARGS; i++) { 01306 if(command_args[i]) 01307 free(command_args[i]); 01308 } 01309 return; 01310 01311 } 01312 01313 /* Zero the buffer */ 01314 memset(message, 0, sizeof(message)); 01315 memset(reply, 0, sizeof(reply)); 01316 01317 /* Call the radio command function */ 01318 (*(auto_cmds[cmd].fun)) (autopilot, mech, command_args, argc, message); 01319 01320 /* If its a silent command there is no reply */ 01321 if(auto_cmds[cmd].silent) { 01322 01323 /* Free args and exit */ 01324 for(i = 0; i < 2; i++) { 01325 if(args[i]) 01326 free(args[i]); 01327 } 01328 for(i = 0; i < AUTOPILOT_MAX_ARGS; i++) { 01329 if(command_args[i]) 01330 free(command_args[i]); 01331 } 01332 return; 01333 01334 } 01335 01336 /* Check to see if a message was returned */ 01337 if(*message) { 01338 01339 /* Check if there was an error message 01340 * otherwise add a front and back to the message */ 01341 if(message[0] == '!') { 01342 snprintf(reply, LBUF_SIZE, "ERROR: %s!", message + 1); 01343 } else { 01344 01345 switch (Number(0, 20)) { 01346 case 0: 01347 case 1: 01348 case 2: 01349 case 4: 01350 snprintf(reply, LBUF_SIZE, "%s%s%s", "Affirmative, ", 01351 message, "."); 01352 break; 01353 case 5: 01354 snprintf(reply, LBUF_SIZE, "%s%s%s", "Nod, ", message, "."); 01355 break; 01356 case 6: 01357 snprintf(reply, LBUF_SIZE, "%s%s%s", "Fine, ", message, "."); 01358 break; 01359 case 7: 01360 snprintf(reply, LBUF_SIZE, "%s%s%s", "Aye aye, Captain, ", 01361 message, "!"); 01362 break; 01363 case 8: 01364 case 9: 01365 case 10: 01366 snprintf(reply, LBUF_SIZE, "%s%s%s", "Da, boss, ", 01367 message, "!"); 01368 break; 01369 case 11: 01370 case 12: 01371 snprintf(reply, LBUF_SIZE, "%s%s%s", "Ok, ", message, "."); 01372 break; 01373 case 13: 01374 snprintf(reply, LBUF_SIZE, "%s%s%s", "Okay, okay, ", 01375 message, ", happy now?"); 01376 break; 01377 case 14: 01378 snprintf(reply, LBUF_SIZE, "%s%s%s", "Okidoki, ", 01379 message, "!"); 01380 break; 01381 case 15: 01382 case 16: 01383 case 17: 01384 snprintf(reply, LBUF_SIZE, "%s%s%s", "Aye, ", message, "."); 01385 break; 01386 default: 01387 snprintf(reply, LBUF_SIZE, "%s%s%s", "Roger, Roger, ", 01388 message, "."); 01389 break; 01390 } /* End of switch */ 01391 01392 } 01393 01394 auto_reply(mech, reply); 01395 01396 } else if(!auto_cmds[cmd].silent) { 01397 01398 /* Command isn't silent but it didn't return a message */ 01399 snprintf(reply, LBUF_SIZE, "Ok."); 01400 auto_reply(mech, reply); 01401 01402 } 01403 01404 /* free args */ 01405 for(i = 0; i < 2; i++) { 01406 if(args[i]) 01407 free(args[i]); 01408 } 01409 for(i = 0; i < AUTOPILOT_MAX_ARGS; i++) { 01410 if(command_args[i]) 01411 free(command_args[i]); 01412 } 01413 01414 }
void auto_radio_command_autogun | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 141 of file autopilot_radio.c.
References AssignedTarget, AUTO_GUN_UPDATE_TICK, DoStartGun, DoStopGun, Gunning, LBUF_SIZE, Readnum, AUTO::target, AUTO::target_score, AUTO::target_threshold, AUTO::target_update_tick, and UnassignTarget.
00143 { 00144 00145 int threshold; 00146 00147 if(strcmp(args[1], "on") == 0) { 00148 00149 autopilot->target = -1; 00150 autopilot->target_score = 0; 00151 autopilot->target_update_tick = AUTO_GUN_UPDATE_TICK; 00152 00153 /* Reset the Assigned target flag */ 00154 if(AssignedTarget(autopilot)) { 00155 UnassignTarget(autopilot); 00156 } 00157 00158 if(Gunning(autopilot)) { 00159 DoStopGun(autopilot); 00160 } 00161 DoStartGun(autopilot); 00162 00163 snprintf(mesg, LBUF_SIZE, "shooting at whatever I want"); 00164 return; 00165 00166 } else if(strcmp(args[1], "off") == 0) { 00167 00168 /* Reset the AI */ 00169 autopilot->target = -2; 00170 autopilot->target_score = 0; 00171 autopilot->target_update_tick = 0; 00172 00173 /* Reset this flag since we don't want to be shooting anything */ 00174 if(AssignedTarget(autopilot)) { 00175 UnassignTarget(autopilot); 00176 } 00177 00178 if(Gunning(autopilot)) 00179 DoStopGun(autopilot); 00180 00181 snprintf(mesg, LBUF_SIZE, "powering down weapons"); 00182 return; 00183 00184 } else if(strcmp(args[1], "threshold") == 0) { 00185 00186 /* Ok user specifying a threshold" */ 00187 /* Right now we're only going to allow them to specify a value 00188 * between 0 and 100 - basicly how much percentage wise over 00189 * the current value does the new target have to be to switch */ 00190 if(argc == 3 && !Readnum(threshold, args[2]) && 00191 threshold >= 0 && threshold <= 100) { 00192 00193 /* Set the new threshold value */ 00194 autopilot->target_threshold = threshold; 00195 00196 snprintf(mesg, LBUF_SIZE, "new threshold set to %d%%", threshold); 00197 return; 00198 00199 } else { 00200 00201 /* Bad value for threshold */ 00202 snprintf(mesg, LBUF_SIZE, "!Invalid value used with threshold: " 00203 "Usage autogun threshold [0-100]"); 00204 return; 00205 00206 } 00207 00208 } 00209 00210 snprintf(mesg, LBUF_SIZE, "!Invalid Input for autogun:" 00211 " use 'on' or 'off'"); 00212 00213 }
void auto_radio_command_chasetarg | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 218 of file autopilot_radio.c.
References AUTO_CHASETARGET_OFF, AUTO_CHASETARGET_ON, auto_set_chasetarget_mode(), and LBUF_SIZE.
00220 { 00221 00222 if(strcmp(args[1], "on") == 0) { 00223 00224 auto_set_chasetarget_mode(autopilot, AUTO_CHASETARGET_ON); 00225 snprintf(mesg, LBUF_SIZE, "Chase Target Mode is Activated"); 00226 return; 00227 00228 } else if(strcmp(args[1], "off") == 0) { 00229 00230 auto_set_chasetarget_mode(autopilot, AUTO_CHASETARGET_OFF); 00231 snprintf(mesg, LBUF_SIZE, "Chase Target Mode is Deactivated"); 00232 return; 00233 } 00234 snprintf(mesg, LBUF_SIZE, 00235 "!Invalid Input for chasetarg: use 'on' or 'off'"); 00236 00237 }
void auto_radio_command_dfollow | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 242 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, FindTargetDBREFFromMapNumber(), LBUF_SIZE, AUTO::mynum, AUTO::ofsx, AUTO::ofsy, and SBUF_SIZE.
00244 { 00245 00246 dbref targetref; 00247 char buffer[SBUF_SIZE]; 00248 00249 targetref = FindTargetDBREFFromMapNumber(mech, args[1]); 00250 if(targetref <= 0) { 00251 snprintf(mesg, LBUF_SIZE, "!Invalid target to follow"); 00252 return; 00253 } 00254 00255 Clear(autopilot); 00256 00257 snprintf(buffer, SBUF_SIZE, "dumbfollow %d", targetref); 00258 auto_addcommand(autopilot->mynum, autopilot, buffer); 00259 auto_engage(autopilot->mynum, autopilot, ""); 00260 snprintf(mesg, LBUF_SIZE, "following %s [dumbly] (%d degrees, %d away)", 00261 args[1], autopilot->ofsx, autopilot->ofsy); 00262 }
void auto_radio_command_dgoto | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 267 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, LBUF_SIZE, AUTO::mynum, Readnum, SBUF_SIZE, x, and y.
00269 { 00270 00271 int x, y; 00272 char buffer[SBUF_SIZE]; 00273 00274 if(Readnum(x, args[1])) { 00275 snprintf(mesg, LBUF_SIZE, "!First number not an integer"); 00276 return; 00277 } 00278 if(Readnum(y, args[2])) { 00279 snprintf(mesg, LBUF_SIZE, "!First number not an integer"); 00280 return; 00281 } 00282 00283 Clear(autopilot); 00284 00285 snprintf(buffer, SBUF_SIZE, "dumbgoto %d %d", x, y); 00286 auto_addcommand(autopilot->mynum, autopilot, buffer); 00287 auto_engage(autopilot->mynum, autopilot, ""); 00288 snprintf(mesg, LBUF_SIZE, "going [dumbly] to %d,%d", x, y); 00289 00290 }
void auto_radio_command_dropoff | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 295 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, LBUF_SIZE, AUTO::mynum, and SBUF_SIZE.
00297 { 00298 00299 char buffer[SBUF_SIZE]; 00300 00301 Clear(autopilot); 00302 00303 snprintf(buffer, SBUF_SIZE, "dropoff"); 00304 auto_addcommand(autopilot->mynum, autopilot, buffer); 00305 auto_engage(autopilot->mynum, autopilot, ""); 00306 snprintf(mesg, LBUF_SIZE, "dropping off"); 00307 00308 }
void auto_radio_command_embark | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 313 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, FindTargetDBREFFromMapNumber(), LBUF_SIZE, AUTO::mynum, and SBUF_SIZE.
00315 { 00316 00317 dbref targetref; 00318 char buffer[SBUF_SIZE]; 00319 00320 targetref = FindTargetDBREFFromMapNumber(mech, args[1]); 00321 if(targetref <= 0) { 00322 snprintf(mesg, LBUF_SIZE, "!Invalid target to embark"); 00323 return; 00324 } 00325 00326 Clear(autopilot); 00327 snprintf(buffer, SBUF_SIZE, "embark %d", targetref); 00328 auto_addcommand(autopilot->mynum, autopilot, buffer); 00329 auto_engage(autopilot->mynum, autopilot, ""); 00330 snprintf(mesg, LBUF_SIZE, "embarking %s", args[1]); 00331 return; 00332 00333 }
void auto_radio_command_enterbase | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 338 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, LBUF_SIZE, AUTO::mynum, and SBUF_SIZE.
00340 { 00341 00342 char buffer[SBUF_SIZE]; 00343 00344 if(argc - 1) { 00345 snprintf(buffer, SBUF_SIZE, "enterbase %s", args[1]); 00346 snprintf(mesg, LBUF_SIZE, "entering base (%s side)", args[1]); 00347 } else { 00348 strncpy(buffer, "enterbase n", SBUF_SIZE); 00349 snprintf(mesg, LBUF_SIZE, "entering base"); 00350 } 00351 00352 Clear(autopilot); 00353 auto_addcommand(autopilot->mynum, autopilot, buffer); 00354 auto_engage(autopilot->mynum, autopilot, ""); 00355 00356 }
void auto_radio_command_follow | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 361 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, FindTargetDBREFFromMapNumber(), LBUF_SIZE, AUTO::mynum, AUTO::ofsx, AUTO::ofsy, and SBUF_SIZE.
00363 { 00364 00365 char buffer[SBUF_SIZE]; 00366 dbref targetref; 00367 00368 targetref = FindTargetDBREFFromMapNumber(mech, args[1]); 00369 if(targetref <= 0) { 00370 snprintf(mesg, LBUF_SIZE, "!Invalid target to follow"); 00371 return; 00372 } 00373 00374 Clear(autopilot); 00375 00376 snprintf(buffer, SBUF_SIZE, "follow %d", targetref); 00377 auto_addcommand(autopilot->mynum, autopilot, buffer); 00378 auto_engage(autopilot->mynum, autopilot, ""); 00379 snprintf(mesg, LBUF_SIZE, "following %s (%d degrees, %d away)", args[1], 00380 autopilot->ofsx, autopilot->ofsy); 00381 00382 }
Definition at line 387 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, getMap(), LBUF_SIZE, MAP::map_height, MAP::map_width, MECH::mapindex, MechX, MechY, AUTO::mynum, Readnum, SBUF_SIZE, x, and y.
00389 { 00390 00391 int x, y; 00392 char buffer[SBUF_SIZE]; 00393 MAP *map; 00394 00395 if(Readnum(x, args[1])) { 00396 snprintf(mesg, LBUF_SIZE, "!First number not integer"); 00397 return; 00398 } 00399 if(Readnum(y, args[2])) { 00400 snprintf(mesg, LBUF_SIZE, "!Second number not integer"); 00401 return; 00402 } 00403 00404 if(MechX(mech) == x && MechY(mech) == y) { 00405 snprintf(mesg, LBUF_SIZE, "!Already in that hex"); 00406 return; 00407 } 00408 00409 map = getMap(mech->mapindex); 00410 00411 if (x < 0 || y < 0 || x >= map->map_width || y >= map->map_height) { 00412 snprintf(mesg, LBUF_SIZE, "!Bad hex to travel to"); 00413 return; 00414 } 00415 00416 Clear(autopilot); 00417 00418 snprintf(buffer, SBUF_SIZE, "goto %d %d", x, y); 00419 auto_addcommand(autopilot->mynum, autopilot, buffer); 00420 auto_engage(autopilot->mynum, autopilot, ""); 00421 snprintf(mesg, LBUF_SIZE, "going to %d,%d", x, y); 00422 00423 }
void auto_radio_command_heading | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 428 of file autopilot_radio.c.
References auto_engage(), Clear, LBUF_SIZE, mech_heading(), mech_speed(), AUTO::mynum, Readnum, and SBUF_SIZE.
00430 { 00431 00432 int heading; 00433 char buffer[SBUF_SIZE]; 00434 00435 if(Readnum(heading, args[1])) { 00436 snprintf(mesg, LBUF_SIZE, "!Number not integer"); 00437 return; 00438 } 00439 00440 Clear(autopilot); 00441 auto_engage(autopilot->mynum, autopilot, ""); 00442 snprintf(buffer, SBUF_SIZE, "%d", heading); 00443 mech_heading(autopilot->mynum, mech, buffer); 00444 strcpy(buffer, "0"); 00445 mech_speed(autopilot->mynum, mech, buffer); 00446 snprintf(buffer, LBUF_SIZE, "stopped and heading changed to %d", heading); 00447 00448 }
Definition at line 453 of file autopilot_radio.c.
References auto_cmds, auto_reply(), LBUF_SIZE, and name.
00455 { 00456 00457 int i; 00458 00461 snprintf(mesg, LBUF_SIZE, "The following commands are possible:"); 00462 00463 for(i = 0; auto_cmds[i].name; i++) { 00464 if(i > 0 && !strcmp(auto_cmds[i].name, auto_cmds[i - 1].name)) 00465 continue; 00466 strncat(mesg, " ", LBUF_SIZE); 00467 strncat(mesg, auto_cmds[i].name, LBUF_SIZE); 00468 } 00469 00470 auto_reply(mech, mesg); 00471 00472 }
Definition at line 477 of file autopilot_radio.c.
References bsuit_hide(), BUILDING, CLASS_BSUIT, CLASS_MW, HasCamo, HEAVY_FOREST, LBUF_SIZE, LIGHT_FOREST, MechRTerrain, MechType, MOUNTAINS, AUTO::mynum, and ROUGH.
00479 { 00480 00481 if((HasCamo(mech)) ? 00482 0 : MechType(mech) != CLASS_BSUIT && MechType(mech) != CLASS_MW) { 00483 snprintf(mesg, LBUF_SIZE, 00484 "!Last I checked I was kind of big for that"); 00485 return; 00486 } 00487 00488 if(!(MechRTerrain(mech) == HEAVY_FOREST || 00489 MechRTerrain(mech) == LIGHT_FOREST || 00490 MechRTerrain(mech) == ROUGH || 00491 MechRTerrain(mech) == MOUNTAINS || 00492 (MechType(mech) == CLASS_BSUIT ? MechRTerrain(mech) == 00493 BUILDING : 0))) { 00494 snprintf(mesg, LBUF_SIZE, "!Invalid Terrain"); 00495 return; 00496 } 00497 00498 bsuit_hide(autopilot->mynum, mech, ""); 00499 snprintf(mesg, LBUF_SIZE, "Begining to hide"); 00500 00501 }
void auto_radio_command_jumpjet | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 507 of file autopilot_radio.c.
References FindTargetDBREFFromMapNumber(), LBUF_SIZE, mech_jump(), MechJumpSpeed, AUTO::mynum, Readnum, and SBUF_SIZE.
00509 { 00510 00511 dbref target; 00512 char buffer[SBUF_SIZE]; 00513 int bear, rng; 00514 00515 if(!abs(MechJumpSpeed(mech))) { 00516 snprintf(mesg, LBUF_SIZE, "!I don't do hiphop and jump around"); 00517 return; 00518 } 00519 00520 if((argc - 1) == 1) { 00521 if((target = FindTargetDBREFFromMapNumber(mech, args[1])) <= 0) { 00522 snprintf(mesg, LBUF_SIZE, "!Unable to see such a target"); 00523 return; 00524 } 00525 strcpy(buffer, args[1]); 00526 mech_jump(autopilot->mynum, mech, buffer); 00527 snprintf(mesg, LBUF_SIZE, "jumping on [%s]", args[1]); 00528 return; 00529 } else { 00530 if(Readnum(bear, args[1])) { 00531 snprintf(mesg, LBUF_SIZE, "!Invalid bearing"); 00532 return; 00533 } 00534 if(Readnum(rng, args[2])) { 00535 snprintf(mesg, LBUF_SIZE, "!Invalid range"); 00536 return; 00537 } 00538 snprintf(buffer, SBUF_SIZE, "%s %s", args[1], args[2]); 00539 mech_jump(autopilot->mynum, mech, buffer); 00540 snprintf(mesg, LBUF_SIZE, "jump %s degrees %s hexes", args[1], 00541 args[2]); 00542 return; 00543 } 00544 }
void auto_radio_command_leavebase | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 549 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), ChasingTarget, Clear, LBUF_SIZE, AUTO::mynum, Readnum, SBUF_SIZE, and StopChasingTarget.
00551 { 00552 00553 char buffer[SBUF_SIZE]; 00554 int direction; 00555 00556 if(Readnum(direction, args[1])) { 00557 snprintf(mesg, LBUF_SIZE, "!Invalid value for direction"); 00558 return; 00559 } 00560 00561 /* Make sure chasetarget doesn't interfere with this */ 00562 if(ChasingTarget(autopilot)) { 00563 StopChasingTarget(autopilot); 00564 } 00565 00566 Clear(autopilot); 00567 00568 snprintf(buffer, SBUF_SIZE, "leavebase %d", direction); 00569 auto_addcommand(autopilot->mynum, autopilot, buffer); 00570 auto_engage(autopilot->mynum, autopilot, ""); 00571 snprintf(mesg, LBUF_SIZE, "leaving base at %d heading", direction); 00572 00573 }
void auto_radio_command_ogoto | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 578 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), Clear, LBUF_SIZE, AUTO::mynum, Readnum, SBUF_SIZE, x, and y.
00580 { 00581 00582 int x, y; 00583 char buffer[SBUF_SIZE]; 00584 00585 if(Readnum(x, args[1])) { 00586 snprintf(mesg, LBUF_SIZE, "!First number not integer"); 00587 return; 00588 } 00589 if(Readnum(y, args[2])) { 00590 snprintf(mesg, LBUF_SIZE, "!Second number not integer"); 00591 return; 00592 } 00593 00594 Clear(autopilot); 00595 00596 snprintf(buffer, SBUF_SIZE, "oldgoto %d %d", x, y); 00597 auto_addcommand(autopilot->mynum, autopilot, buffer); 00598 auto_engage(autopilot->mynum, autopilot, ""); 00599 snprintf(mesg, LBUF_SIZE, "going [old version] to %d,%d", x, y); 00600 00601 }
void auto_radio_command_pickup | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 606 of file autopilot_radio.c.
References auto_addcommand(), auto_engage(), ChasingTarget, Clear, FindTargetDBREFFromMapNumber(), LBUF_SIZE, AUTO::mynum, SBUF_SIZE, and StopChasingTarget.
00608 { 00609 00610 dbref targetref; 00611 char buffer[SBUF_SIZE]; 00612 00613 targetref = FindTargetDBREFFromMapNumber(mech, args[1]); 00614 if(targetref <= 0) { 00615 snprintf(mesg, LBUF_SIZE, "!Invalid target to pickup"); 00616 return; 00617 } 00618 00619 /* Make sure chasetarget doesn't interfere with this */ 00620 if(ChasingTarget(autopilot)) { 00621 StopChasingTarget(autopilot); 00622 } 00623 00624 Clear(autopilot); 00625 00626 snprintf(buffer, SBUF_SIZE, "pickup %d", targetref); 00627 auto_addcommand(autopilot->mynum, autopilot, buffer); 00628 auto_engage(autopilot->mynum, autopilot, ""); 00629 snprintf(mesg, LBUF_SIZE, "picking up %s", args[1]); 00630 00631 }
void auto_radio_command_position | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 637 of file autopilot_radio.c.
References LBUF_SIZE, AUTO::ofsx, AUTO::ofsy, Readnum, x, and y.
00639 { 00640 00641 int x, y; 00642 00645 if(Readnum(x, args[1])) { 00646 snprintf(mesg, LBUF_SIZE, "!Invalid first int"); 00647 return; 00648 } 00649 if(Readnum(y, args[2])) { 00650 snprintf(mesg, LBUF_SIZE, "!Invalide second int"); 00651 return; 00652 } 00653 00654 autopilot->ofsx = x; 00655 autopilot->ofsy = y; 00656 snprintf(mesg, LBUF_SIZE, "following %d degrees, %d away", x, y); 00657 00658 }
void auto_radio_command_prone | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 663 of file autopilot_radio.c.
References LBUF_SIZE, mech_drop(), and AUTO::mynum.
00665 { 00666 00667 mech_drop(autopilot->mynum, mech, ""); 00668 snprintf(mesg, LBUF_SIZE, "hitting the deck"); 00669 00670 }
void auto_radio_command_report | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 676 of file autopilot_radio.c.
References auto_reply(), Fallen, FaMechRange, getMech(), GetMechToMechID(), InLineOfSight(), IsRunning, Jumping, LBUF_SIZE, MBUF_SIZE, MechFacing, MechSpeed, MechTarget, MechX, MechY, and MMaxSpeed.
00678 { 00679 00680 char buffer[MBUF_SIZE]; 00681 MECH *target; 00682 00683 /* Is the AI moving or something */ 00684 if(Jumping(mech)) 00685 strcpy(buffer, "Jumping"); 00686 else if(Fallen(mech)) 00687 strcpy(buffer, "Prone"); 00688 else if(IsRunning(MechSpeed(mech), MMaxSpeed(mech))) 00689 strcpy(buffer, "Running"); 00690 else if(MechSpeed(mech) > 1.0) 00691 strcpy(buffer, "Walking"); 00692 else 00693 strcpy(buffer, "Standing"); 00694 00695 snprintf(mesg, LBUF_SIZE, "%s at %d, %d", buffer, MechX(mech), 00696 MechY(mech)); 00697 00698 /* Which way is the AI going */ 00699 if(MechSpeed(mech) > 1.0) { 00700 snprintf(buffer, MBUF_SIZE, ", headed %d speed %.2f", 00701 MechFacing(mech), MechSpeed(mech)); 00702 strncat(mesg, buffer, LBUF_SIZE); 00703 } else { 00704 snprintf(buffer, MBUF_SIZE, ", headed %d", MechFacing(mech)); 00705 strncat(mesg, buffer, LBUF_SIZE); 00706 } 00707 00708 /* Is the AI targeting something */ 00709 if(MechTarget(mech) != -1) { 00710 target = getMech(MechTarget(mech)); 00711 00712 if(target) { 00713 snprintf(buffer, MBUF_SIZE, ", targeting %s %s", 00714 GetMechToMechID(mech, target), 00715 InLineOfSight(mech, target, MechX(target), 00716 MechY(target), FaMechRange(mech, target)) ? 00717 "" : "(not in LOS)"); 00718 strncat(mesg, buffer, LBUF_SIZE); 00719 } 00720 } 00721 00722 /* Send the mesg to the reply system, this is a silent command */ 00723 auto_reply(mech, mesg); 00724 00725 }
void auto_radio_command_reset | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 730 of file autopilot_radio.c.
References auto_delcommand(), auto_disengage(), auto_engage(), auto_init(), LBUF_SIZE, AUTO::mynum, and SBUF_SIZE.
00732 { 00733 00734 char buffer[SBUF_SIZE]; 00735 00736 auto_disengage(autopilot->mynum, autopilot, ""); 00737 auto_delcommand(autopilot->mynum, autopilot, "-1"); 00738 auto_init(autopilot, mech); 00739 auto_engage(autopilot->mynum, autopilot, ""); 00740 snprintf(mesg, LBUF_SIZE, "all internal events and flags reset!"); 00741 00742 }
void auto_radio_command_sensor | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 748 of file autopilot_radio.c.
References AUTOPILOT_LSENS, EVENT_AUTO_SENSOR, AUTO::flags, LBUF_SIZE, mech_sensor(), muxevent_remove_type_data(), AUTO::mynum, and SBUF_SIZE.
00750 { 00751 00752 char buf[SBUF_SIZE]; 00753 00754 /* Make sure no sensor event running */ 00755 muxevent_remove_type_data(EVENT_AUTO_SENSOR, autopilot); 00756 00757 if((argc - 1) == 2) { 00758 00759 /* Set the user specified sensors */ 00760 snprintf(buf, SBUF_SIZE, "%s %s", args[1], args[2]); 00761 mech_sensor(autopilot->mynum, mech, buf); 00762 autopilot->flags |= AUTOPILOT_LSENS; 00763 snprintf(mesg, LBUF_SIZE, "updated my sensors"); 00764 return; 00765 00766 } 00767 00768 /* Let AI decide */ 00769 autopilot->flags &= ~AUTOPILOT_LSENS; 00770 snprintf(mesg, LBUF_SIZE, "using my own judgement with sensors"); 00771 return; 00772 00773 }
void auto_radio_command_shutdown | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 778 of file autopilot_radio.c.
References LBUF_SIZE, mech_shutdown(), and AUTO::mynum.
00780 { 00781 00782 mech_shutdown(autopilot->mynum, mech, ""); 00783 snprintf(mesg, LBUF_SIZE, "shutting down"); 00784 00785 }
void auto_radio_command_speed | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 790 of file autopilot_radio.c.
References LBUF_SIZE, Readnum, and AUTO::speed.
00792 { 00793 00794 int speed = 100; 00795 00796 if(Readnum(speed, args[1])) { 00797 snprintf(mesg, LBUF_SIZE, "!Invalid value - not a number"); 00798 return; 00799 } 00800 00801 if(speed < 1 || speed > 100) { 00802 snprintf(mesg, LBUF_SIZE, "!Invalid speed"); 00803 return; 00804 } 00805 00806 autopilot->speed = speed; 00807 snprintf(mesg, LBUF_SIZE, "setting speed to %d %%", speed); 00808 00809 }
void auto_radio_command_stand | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 814 of file autopilot_radio.c.
References LBUF_SIZE, mech_stand(), and AUTO::mynum.
00816 { 00817 00818 mech_stand(autopilot->mynum, mech, ""); 00819 snprintf(mesg, LBUF_SIZE, "standing up"); 00820 00821 }
void auto_radio_command_startup | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 826 of file autopilot_radio.c.
References LBUF_SIZE, mech_startup(), and AUTO::mynum.
00828 { 00829 00830 if(argc > 1) { 00831 if(!strncasecmp(args[1], "override", strlen(args[1]))) { 00832 mech_startup(autopilot->mynum, mech, "override"); 00833 snprintf(mesg, LBUF_SIZE, "emergency override startup triggered"); 00834 return; 00835 } 00836 } 00837 00838 mech_startup(autopilot->mynum, mech, ""); 00839 snprintf(mesg, LBUF_SIZE, "starting up"); 00840 00841 }
Definition at line 846 of file autopilot_radio.c.
References AUTO_CHASETARGET_OFF, auto_engage(), auto_set_chasetarget_mode(), Clear, LBUF_SIZE, mech_speed(), AUTO::mynum, and SBUF_SIZE.
00848 { 00849 00850 char buffer[SBUF_SIZE]; 00851 00852 strcpy(buffer, "0"); 00853 00854 /* Turn chasetarget off */ 00855 auto_set_chasetarget_mode(autopilot, AUTO_CHASETARGET_OFF); 00856 00857 Clear(autopilot); 00858 00859 auto_engage(autopilot->mynum, autopilot, ""); 00860 mech_speed(autopilot->mynum, mech, buffer); 00861 snprintf(mesg, LBUF_SIZE, "halting"); 00862 00863 }
void auto_radio_command_sweight | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 868 of file autopilot_radio.c.
References AUTO::auto_fweight, AUTO::auto_goweight, LBUF_SIZE, MAX, Readnum, x, and y.
00870 { 00871 00872 int x, y; 00873 00874 if(Readnum(x, args[1])) { 00875 snprintf(mesg, LBUF_SIZE, "!Invalid first int"); 00876 return; 00877 } 00878 if(Readnum(y, args[2])) { 00879 snprintf(mesg, LBUF_SIZE, "!Invalide second int"); 00880 return; 00881 } 00882 x = MAX(1, x); 00883 y = MAX(1, y); 00884 autopilot->auto_goweight = x; 00885 autopilot->auto_fweight = y; 00886 snprintf(mesg, LBUF_SIZE, "sweight'ed to %d:%d. (go:fight)", x, y); 00887 return; 00888 00889 }
void auto_radio_command_target | ( | AUTO * | autopilot, | |
MECH * | mech, | |||
char ** | args, | |||
int | argc, | |||
char * | mesg | |||
) |
Definition at line 894 of file autopilot_radio.c.
References AssignedTarget, AssignTarget, AUTO_GUN_UPDATE_TICK, DoStartGun, DoStopGun, FindTargetDBREFFromMapNumber(), Gunning, LBUF_SIZE, AUTO::target, AUTO::target_score, AUTO::target_update_tick, and UnassignTarget.
00896 { 00897 00898 dbref targetref; 00899 00900 if(!strcmp(args[1], "-")) { 00901 00902 /* Basicly doing the same as 'autogun on' */ 00903 autopilot->target = -1; 00904 autopilot->target_score = 0; 00905 autopilot->target_update_tick = AUTO_GUN_UPDATE_TICK; 00906 00907 if(AssignedTarget(autopilot)) { 00908 UnassignTarget(autopilot); 00909 } 00910 00911 if(Gunning(autopilot)) { 00912 DoStopGun(autopilot); 00913 } 00914 DoStartGun(autopilot); 00915 00916 snprintf(mesg, LBUF_SIZE, "shooting at whatever I want"); 00917 return; 00918 00919 } else { 00920 00921 targetref = FindTargetDBREFFromMapNumber(mech, args[1]); 00922 if(targetref <= 0) { 00923 snprintf(mesg, LBUF_SIZE, "!Unable to see such a target"); 00924 return; 00925 } 00926 00927 } 00928 00929 autopilot->target = targetref; 00930 autopilot->target_score = 0; 00931 autopilot->target_update_tick = 0; 00932 00933 /* Let the AI know its an assigned target */ 00934 if(!AssignedTarget(autopilot)) { 00935 AssignTarget(autopilot); 00936 } 00937 00938 if(Gunning(autopilot)) { 00939 DoStopGun(autopilot); 00940 } 00941 DoStartGun(autopilot); 00942 00943 snprintf(mesg, LBUF_SIZE, "aiming for [%s] (and ignoring everyone else)", 00944 args[1]); 00945 00946 }
void auto_reply | ( | MECH * | mech, | |
char * | buf | |||
) |
Definition at line 1196 of file autopilot_radio.c.
References auto_reply_event(), EVENT_AUTO_REPLY, FindObjectsData(), MECH::freq, Good_obj, Location, MechAuto, MECHEVENT, MECH::mynum, Number, and SendAI.
01197 { 01198 01199 char *reply; 01200 01201 /* No zero freq messages */ 01202 if(!mech->freq[0]) 01203 return; 01204 01205 /* Make sure there is an autopilot */ 01206 if(MechAuto(mech) <= 0) 01207 return; 01208 01209 /* Make sure valid objects */ 01210 if(!(FindObjectsData(MechAuto(mech))) || 01211 !Good_obj(MechAuto(mech)) || Location(MechAuto(mech)) != mech->mynum) { 01212 MechAuto(mech) = -1; 01213 return; 01214 } 01215 01216 /* Copy the buffer */ 01217 reply = strdup(buf); 01218 01219 if(reply) { 01220 MECHEVENT(mech, EVENT_AUTO_REPLY, auto_reply_event, Number(1, 2), 01221 reply); 01222 } else { 01223 SendAI 01224 ("Interal AI Error: Attempting to radio reply but unable to copy string"); 01225 } 01226 01227 }
void auto_reply_event | ( | MUXEVENT * | muxevent | ) |
Definition at line 1172 of file autopilot_radio.c.
References my_event_type::data, my_event_type::data2, getMap(), IsMech, MECH::mapindex, MECH::mynum, and sendchannelstuff().
Referenced by auto_reply().
01173 { 01174 01175 MECH *mech = (MECH *) muxevent->data; 01176 char *buf = (char *) muxevent->data2; 01177 MAP *map; 01178 01179 /* Make sure its a mech */ 01180 if(!IsMech(mech->mynum)) { 01181 free(buf); 01182 return; 01183 } 01184 01185 /* If valid object */ 01186 if(mech) 01187 if((map = (getMap(mech->mapindex)))) 01188 sendchannelstuff(mech, 0, buf); 01189 01190 free(buf); 01191 }
void sendchannelstuff | ( | MECH * | mech, | |
int | freq, | |||
char * | msg | |||
) |
Definition at line 1096 of file mech.notify.c.
References A_FACTION, AccumulateCommXP(), AnyECMDisturbed, auto_parse_command(), ccode, MECH::chantitle, comm_mech, Destroyed, ECMDisturbed, FaMechRange, FindBearing(), findCommLink(), FindObjectsData(), MAP::first_free, MECH::freq, FREQ_DIGITAL, FREQ_INFO, FREQ_MUTE, FREQ_SCAN, MECH::freqmodes, getMap(), In_Character, LBUF_SIZE, Location, MECH::mapindex, MAX, mech_notify(), mech_printf(), MECHALL, MechAuto, MechComm, MechCommLast, MechCritStatus, MechFX, MechFY, MechIDS(), MechPilot, MechRadioInfo, MechRadioRange, MAP::mechsOnMap, MechTeam, MFreqs, MIN, muxevent_tick, AUTO::mynum, MECH::mynum, Number, OBSERVATORIC, RADIO_NODIGITAL, RADIO_SCAN, ScrambleMessage(), SendAI, and silly_atr_get().
Referenced by auto_reply_event().
01097 { 01098 /* The _smart_ code :-) */ 01099 int loop, range, bearing, i, isxp; 01100 MECH *tempMech; 01101 MAP *mech_map = getMap(mech->mapindex); 01102 char buf[LBUF_SIZE]; 01103 char buf2[LBUF_SIZE]; 01104 char buf3[LBUF_SIZE]; 01105 int sfail_type, sfail_mod; 01106 int rfail_type, rfail_mod; 01107 int obs = 0; 01108 01109 char ai_buf[LBUF_SIZE]; 01110 01111 /* Removed the Radio Failing stuff cause it annoys me - Dany 01112 CheckGenericFail(mech, -2, &sfail_type, &sfail_mod); 01113 */ 01114 if(!MechRadioRange(mech)) 01115 return; 01116 01117 /* Loop through all the units on the map */ 01118 for(loop = 0; loop < mech_map->first_free; loop++) { 01119 if(mech_map->mechsOnMap[loop] != 2) { 01120 // XXX: The test below is indicative of very bad bookkeeping. Suggesting 01121 // that a dbref may be indicated as "on the map" without being on the map. 01122 // I believe this to be a serious problem. 01123 if(! 01124 (tempMech = 01125 (MECH *) FindObjectsData(mech_map->mechsOnMap[loop]))) 01126 continue; 01127 if(Destroyed(tempMech)) 01128 continue; 01129 obs = (MechCritStatus(tempMech) & OBSERVATORIC); 01130 range = FaMechRange(mech, tempMech); 01131 bearing = FindBearing(MechFX(tempMech), MechFY(tempMech), 01132 MechFX(mech), MechFY(mech)); 01133 for(i = 0; i < MFreqs(tempMech); i++) { 01134 if(tempMech->freq[i] == mech->freq[freq] || obs) { 01135 if((tempMech->freqmodes[i] & FREQ_MUTE) || 01136 ((mech->freqmodes[freq] & FREQ_DIGITAL) && 01137 (MechRadioInfo(tempMech) & RADIO_NODIGITAL))) 01138 continue; 01139 break; 01140 } 01141 } 01142 if(i >= MFreqs(tempMech)) { 01143 /* Possible scanner check */ 01144 if(!(mech->freqmodes[freq] & FREQ_DIGITAL)) 01145 if((MechRadioInfo(tempMech) & RADIO_SCAN) && 01146 mech->freq[freq]) { 01147 int tnc = 0; 01148 01149 for(i = 0; i < MFreqs(tempMech); i++) 01150 if(tempMech->freqmodes[i] & FREQ_SCAN) { 01151 int l = strlen(msg), t; 01152 int mod, diff; 01153 int pr; 01154 01155 /* Possible skill check here? Nah. */ 01156 01157 /* Chance of detection: 1 in MIN(80,l) out of 100 */ 01158 if(Number(1, 100) > MIN(80, l)) 01159 continue; 01160 01161 if(!tnc++) 01162 mech_notify(tempMech, MECHALL, 01163 "You notice a " 01164 "unknown transmission your scanner.. "); 01165 if(tempMech->freq[i] < mech->freq[freq]) { 01166 diff = 01167 mech->freq[freq] - tempMech->freq[i]; 01168 mod = 1; 01169 } else { 01170 diff = 01171 tempMech->freq[i] - mech->freq[freq]; 01172 mod = -1; 01173 } 01174 01175 t = MAX(1, 01176 Number(1, MIN(99, l)) * diff / 100); 01177 pr = t * 100 / diff; 01178 mech_printf(tempMech, MECHALL, "Your systems " 01179 "manage to zero on it %s on channel %c.", 01180 pr < 30 ? "somewhat" : pr < 60 ? 01181 "fairly well" : pr < 95 ? 01182 "precisely" : "exactly", i + 'A'); 01183 tempMech->freq[i] += mod * t; 01184 } 01185 01186 } 01187 01188 continue; 01189 01190 } 01191 01192 strncpy(buf2, msg, LBUF_SIZE); 01193 01194 /* Let's just do the OBSERVERIC Stuff here. No sense checking 01195 * elsewhere. We'll compose the message and send it now since 01196 * it should technically hear everything */ 01197 01198 if(obs) { 01199 if(mech->freqmodes[freq] & FREQ_DIGITAL) { 01200 snprintf(buf, LBUF_SIZE, "%s[%c:%d] <%s:%s:%d> <%s> %s%%c", 01201 ccode(tempMech, i, obs, MechTeam(mech)), 01202 (char) ('A' + i), bearing, 01203 silly_atr_get(mech->mynum, A_FACTION), 01204 MechIDS(mech, 0), mech->freq[freq], mech->chantitle[freq],buf2); 01205 } else { 01206 snprintf(buf, LBUF_SIZE, "%s(%c:%d) <%s:%s:%d> <%s> %s%%c", 01207 ccode(tempMech, i, obs, MechTeam(mech)), 01208 (char) ('A' + i), bearing, 01209 silly_atr_get(mech->mynum, A_FACTION), 01210 MechIDS(mech, 0), mech->freq[freq], mech->chantitle[freq],buf2); 01211 } 01212 mech_notify(tempMech, MECHALL, buf); 01213 } 01214 01215 /* This is where we check to see if the mech has an AI and 01216 * then we give the radio commands to the AI */ 01217 if(MechAuto(tempMech) > 0 && tempMech->freq[i]) { 01218 AUTO *a = (AUTO *) FindObjectsData(MechAuto(tempMech)); 01219 01220 /* First check to make sure the AI is still there */ 01221 if(!a) { 01222 /* No AI there so reset the AI value on the mech */ 01223 MechAuto(tempMech) = -1; 01224 } else if(a && Location(a->mynum) != tempMech->mynum) { 01225 /* Check to see if the AI is still in the same mech */ 01226 snprintf(ai_buf, LBUF_SIZE, 01227 "Autopilot #%d (Location: #%d) " 01228 "reported on Mech #%d but not in the proper location", 01229 a->mynum, Location(a->mynum), tempMech->mynum); 01230 SendAI(ai_buf); 01231 } else if(a && !ECMDisturbed(tempMech)) { 01232 /* Ok send the command to the AI provided its not ECM'd */ 01233 strncpy(buf3, msg, LBUF_SIZE); 01234 auto_parse_command(a, tempMech, i, buf3); 01235 } 01236 } 01237 /* Removed the Radio fail stuff because it annoys me - Dany 01238 CheckGenericFail(tempMech, -2, &rfail_type, &rfail_mod); 01239 */ 01240 if(!MechRadioRange(tempMech)) 01241 continue; 01242 if(mech->freqmodes[freq] & FREQ_DIGITAL) { 01243 if(range > MechRadioRange(mech)) { 01244 if(!findCommLink 01245 (mech_map, mech, tempMech, mech->freq[freq])) 01246 continue; 01247 } else 01248 comm_best = 1; 01249 01250 if(tempMech != mech) { 01251 if(AnyECMDisturbed(mech)) 01252 continue; 01253 else if(AnyECMDisturbed(tempMech)) 01254 continue; 01255 } 01256 01257 ScrambleMessage(buf3, range, MechRadioRange(mech), 01258 MechRadioRange(mech), mech->chantitle[freq], 01259 buf2, MechComm(tempMech), &isxp, 0, 01260 (tempMech->freqmodes[i] & FREQ_INFO) ? 2 : 1); 01261 01262 if(comm_best >= 2) 01263 bearing = FindBearing(MechFX(tempMech), MechFY(tempMech), 01264 MechFX(comm_mech 01265 [comm_best_path 01266 [comm_best - 1]]), 01267 MechFY(comm_mech 01268 [comm_best_path 01269 [comm_best - 1]])); 01270 if(!obs) 01271 snprintf(buf, LBUF_SIZE, "%s[%c:%.3d] %s%%c", 01272 ccode(tempMech, i, obs, MechTeam(mech)), 01273 (char) ('A' + i), bearing, buf3); 01274 01275 } else { 01276 01277 ScrambleMessage(buf3, range, MechRadioRange(mech), 01278 MechRadioRange(tempMech), 01279 mech->chantitle[freq], buf2, 01280 MechComm(tempMech), &isxp, 01281 (AnyECMDisturbed(mech) 01282 || AnyECMDisturbed(tempMech) 01283 /* 01284 || sfail_type == FAIL_STATIC || 01285 rfail_type == FAIL_STATIC 01286 */ 01287 ) && mech != tempMech, 0); 01288 if(!obs) 01289 snprintf(buf, LBUF_SIZE, "%s(%c:%.3d) %s%%c", 01290 ccode(tempMech, i, obs, MechTeam(mech)), 01291 (char) ('A' + i), bearing, buf3); 01292 01293 } 01294 01295 if(!obs) 01296 mech_notify(tempMech, MECHALL, buf); 01297 if(isxp && In_Character(tempMech->mynum)) 01298 if((MechCommLast(tempMech) + 60) < muxevent_tick) { 01299 AccumulateCommXP(MechPilot(tempMech), tempMech); 01300 MechCommLast(tempMech) = muxevent_tick; 01301 } 01302 01303 } 01304 } /* End of looping through all the units on the map */ 01305 }
int args |
Definition at line 58 of file autopilot_radio.c.
Referenced by add_entrances(), add_links(), addtic_sub(), aero_checklz(), aero_thrust(), aero_vheading(), atr_match1(), auto_addcommand(), auto_command_autogun(), auto_command_roam(), auto_parse_command(), cleartic_sub(), debug_list(), debug_makemechs(), debug_setvrt(), debug_setxplevel(), debug_shutdown(), deltic_sub(), FindBSuitTarget(), firetic_sub(), initiate_ood(), listtic_sub(), map_add_block(), map_add_mine(), map_addfire(), map_addhex(), map_addice(), map_addsmoke(), map_delice(), map_delobj(), map_listmechs(), map_loadmap(), map_pathfind(), map_savemap(), map_setconditions(), map_setmapsize(), map_view(), mech_attachcables(), mech_bearing(), mech_bomb(), mech_bootlegger(), mech_c3_join_leave(), mech_c3i_join_leave(), mech_contacts(), mech_createbays(), mech_critstatus(), mech_damage(), mech_detachcables(), mech_disableweap(), mech_dump(), mech_embark(), mech_enterbase(), mech_enterbay(), mech_eta(), mech_explode(), mech_fireweapon(), mech_heading(), mech_hulldown(), mech_inarc_ammo_toggle(), mech_jump(), mech_lrsmap(), mech_mechprefs(), mech_navigate(), mech_pickup(), mech_rac(), mech_radio(), mech_range(), mech_report(), mech_rotatetorso(), mech_Rsetmapindex(), mech_Rsetteam(), mech_Rsetxy(), mech_scan(), mech_sendchannel(), mech_sensor(), mech_settarget(), mech_sight(), mech_snipe(), mech_speed(), mech_spot(), mech_stand(), mech_tacmap(), mech_tag(), mech_target(), mech_toggle_mode_sub(), mech_turret(), mech_unjamammo(), mech_usebin(), mech_vector(), mech_vertical(), mech_view(), mechrep_Raddspecial(), mechrep_Raddweap(), mechrep_Rdisplaysection(), mechrep_Rfiremode(), mechrep_Rloadnew(), mechrep_Rreload(), mechrep_Rrepair(), mechrep_Rsavetemp(), mechrep_Rsavetemp2(), mechrep_Rsetarmor(), mechrep_Rsetmove(), mechrep_Rsetradio(), mechrep_Rsettarget(), mechrep_Rsettype(), mechrep_setcargospace(), notify_checked(), process_cmdent(), remove_inarc_pods_mech(), set_xcodestuff(), stuff_change_sub(), tech_parsegun(), and tech_parsepart_advanced().
struct { ... } auto_cmds[] |
Referenced by auto_parse_command(), and auto_radio_command_help().
Referenced by SelCol_FunStringMenu(), and SelCol_FunStringMenuK().
char* name |
Definition at line 57 of file autopilot_radio.c.
char* sho |
int silent |