void mech_move_event(EVENT * e) { MECH *mech = (MECH *) e->data; if (MechType(mech) == CLASS_VTOL) if (Landed(mech) || FuelCheck(mech)) return; UpdateHeading(mech); if ((IsMechLegLess(mech)) || Jumping(mech) || OODing(mech)) { if (MechDesiredFacing(mech) != MechFacing(mech)) MECHEVENT(mech, EVENT_MOVE, mech_move_event, MOVE_TICK, 0); return; } UpdateSpeed(mech); move_mech(mech); if (mech->mapindex < 0) return; if (MechType(mech) == CLASS_VEH_NAVAL && MechRTerrain(mech) != BRIDGE && MechRTerrain(mech) != ICE && MechRTerrain(mech) != WATER) return; if (MechSpeed(mech) || MechDesiredSpeed(mech) || MechDesiredFacing(mech) != MechFacing(mech) || ((MechType(mech) == CLASS_VTOL || MechMove(mech) == MOVE_SUB) && MechVerticalSpeed(mech))) MECHEVENT(mech, EVENT_MOVE, mech_move_event, MOVE_TICK, 0); }
int calcWeatherPilotEffects(MECH * mech) { MAP *map = FindObjectsData(mech->mapindex); int onTheGround = 1; int mod = 0; if (!map) return 0; onTheGround = (!Jumping(mech) && (MechZ(mech) <= Elevation(map, MechX(mech), MechY(mech)))); if (onTheGround) { if ((MapEffectHvyRain(map) || MapEffectHvySnow(map) || MapEffectHighWinds(map) || MapEffectBlizzard(map))) mod += 1; if (MechMove(mech) != MOVE_HOVER) { if (HexHasDeepSnow(map, MechX(mech), MechY(mech))) mod += 1; if (HexHasMud(map, MechX(mech), MechY(mech))) mod += 1; if (HexHasRapids(map, MechX(mech), MechY(mech))) mod += 2; } return mod; } return 0; }
void showNetworkData(dbref player, MECH * mech, int tIsC3) { int i, bearing; MECH *otherMech; float range; char buff[100]; char *mech_name; char move_type[30]; int networkSize; dbref myNetwork[C3_NETWORK_SIZE]; notify_printf(player, "%s Network Status:", tIsC3 ? "C3" : "C3i"); buildTempNetwork(mech, myNetwork, &networkSize, 1, 1, 0, tIsC3); for(i = 0; i < networkSize; i++) { otherMech = getMechInTempNetwork(i, myNetwork, networkSize); if(!otherMech) continue; if(!Good_obj(otherMech->mynum)) continue; range = FlMechRange(objMap, mech, otherMech); bearing = FindBearing(MechFX(mech), MechFY(mech), MechFX(otherMech), MechFY(otherMech)); strcpy(move_type, GetMoveTypeID(MechMove(otherMech))); mech_name = silly_atr_get(otherMech->mynum, A_MECHNAME); sprintf(buff, "%%ch%%cy[%s]%c %-12.12s x:%3d y:%3d z:%3d r:%4.1f b:%3d s:%5.1f h:%3d a: %3d i: %3d%%cn", MechIDS(otherMech, 1), move_type[0], mech_name, MechX(otherMech), MechY(otherMech), MechZ(otherMech), range, bearing, MechSpeed(otherMech), MechVFacing(otherMech), getRemainingArmorPercent(otherMech), getRemainingInternalPercent(otherMech)); notify(player, buff); } notify_printf(player, "End %s Network Status", tIsC3 ? "C3" : "C3i"); }
int tech_parsepart_advanced(MECH * mech, char *buffer, int *loc, int *pos, int *extra, int allowrear) { char *args[5]; int l, argc, isrear = 0; if(!(argc = mech_parseattributes(buffer, args, 4))) return -1; if(argc > (2 + (extra != NULL))) return -1; if(!allowrear) { if((!extra && argc != (1 + (pos != NULL))) || (extra && (argc < (1 + (pos != NULL)) || argc > (2 + (pos != NULL))))) return -1; } else { if(argc == 2) { if(toupper(args[1][0]) != 'R') return -1; isrear = 8; } } if((*loc = ArmorSectionFromString(MechType(mech), MechMove(mech), args[0])) < 0) return -1; if(allowrear) *loc += isrear; if(pos) { l = atoi(args[1]) - 1; if(l < 0 || l >= CritsInLoc(mech, *loc)) return -2; *pos = l; } if(extra) { if(argc > 2) *extra = args[2][0]; else *extra = 0; } return 0; }
int tech_parsegun(MECH * mech, char *buffer, int *loc, int *pos, int *brand) { char *args[3]; int l, argc, t, c = 0, pi, pb; argc = mech_parseattributes(buffer, args, 3); if(argc < 1 || argc > (2 + (brand != NULL))) return -1; if(argc == (2 + (brand != NULL)) || (brand && argc == 2 && atoi(args[1]))) { if((*loc = ArmorSectionFromString(MechType(mech), MechMove(mech), args[0])) < 0) return -1; l = atoi(args[1]); if(l <= 0 || l > CritsInLoc(mech, *loc)) return -4; *pos = l - 1; } else { /* Check if it's a number */ if(args[0][0] < '0' || args[0][0] > '9') return -1; l = atoi(args[0]); if(l < 0) return -1; if((t = FindWeaponNumberOnMech(mech, l, loc, pos)) == -1) return -1; } t = GetPartType(mech, *loc, *pos); if(brand != NULL && argc > 1 && !atoi(args[argc - 1])) { if(!find_matching_long_part(args[argc - 1], &c, &pi, &pb)) return -2; if(pi != t) return -3; *brand = pb; } else if(brand != NULL) *brand = GetPartBrand(mech, *loc, *pos); return 0; }
static void fix_entry(dbref player, MECH * mech, int n) { char buf[MBUF_SIZE]; char *c; /* whee */ n--; c = ShortArmorSectionString(MechType(mech), MechMove(mech), damage_table[n][1]); switch (damage_table[n][0]) { case REPAIRP_T: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_repairgun(player, mech, buf); break; case ENHCRIT_MISC: case ENHCRIT_FOCUS: case ENHCRIT_CRYSTAL: case ENHCRIT_BARREL: case ENHCRIT_AMMOB: case ENHCRIT_RANGING: case ENHCRIT_AMMOM: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_fixenhcrit(player, mech, buf); break; case REPAIRG: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_replacegun(player, mech, buf); break; case REPAIRP: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_replacepart(player, mech, buf); break; case RELOAD: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_reload(player, mech, buf); break; case REATTACH: sprintf(buf, "%s", c); tech_reattach(player, mech, buf); break; case RESEAL: sprintf(buf, "%s", c); tech_reseal(player, mech, buf); break; case FIXARMOR: sprintf(buf, "%s", c); tech_fixarmor(player, mech, buf); break; case FIXARMOR_R: sprintf(buf, "%s r", c); tech_fixarmor(player, mech, buf); break; case FIXINTERNAL: sprintf(buf, "%s", c); tech_fixinternal(player, mech, buf); break; case DETACH: sprintf(buf, "%s", c); tech_removesection(player, mech, buf); break; case SCRAPP: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_removepart(player, mech, buf); break; case SCRAPG: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_removegun(player, mech, buf); break; case UNLOAD: sprintf(buf, "%s %d", c, damage_table[n][2] + 1); tech_unload(player, mech, buf); break; case REPLACESUIT: sprintf(buf, "%s", c); tech_replacesuit(player, mech, buf); break; } }
void show_mechs_damage(dbref player, void *data, char *buffer) { MECH *mech = data; coolmenu *c = NULL; int i, j, v1, v2; char buf[MBUF_SIZE]; char buf2[MBUF_SIZE]; int isds; TECHCOMMANDD; if (unit_is_fixable(mech)) make_damage_table(mech); else make_scrap_table(mech); DOCHECK(!damage_last && MechType(mech) == CLASS_MECH, "The 'mech is in pristine condition!"); DOCHECK(!damage_last, "It's in pristine condition!"); addline(); cent(tprintf("Damage for %s", GetMechID(mech))); addline(); for (i = 0; i < damage_last; i++) { v1 = damage_table[i][1]; v2 = damage_table[i][2]; switch (damage_table[i][0]) { case REATTACH: case DETACH: case RESEAL: case REPLACESUIT: strcpy(buf, repair_need_msgs[(int) damage_table[i][0]]); break; case REPAIRP: case REPAIRP_T: case REPAIRG: case ENHCRIT_MISC: case ENHCRIT_FOCUS: case ENHCRIT_CRYSTAL: case ENHCRIT_BARREL: case ENHCRIT_AMMOB: case ENHCRIT_RANGING: case ENHCRIT_AMMOM: case SCRAPP: case SCRAPG: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], pos_part_name(mech, v1, v2)); break; case RELOAD: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], pos_part_name(mech, v1, v2), FullAmmo(mech, v1, v2) - GetPartData(mech, v1, v2)); break; case UNLOAD: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], pos_part_name(mech, v1, v2), GetPartData(mech, v1, v2)); break; case FIXARMOR: case FIXARMOR_R: case FIXINTERNAL: sprintf(buf, repair_need_msgs[(int) damage_table[i][0]], damage_table[i][2]); break; } j = is_under_repair(mech, i); sprintf(buf2, "%%ch%s%-2d:%s %%cn%s%s", j ? "%cg" : "%cy", i + 1, ShortArmorSectionString(MechType(mech), MechMove(mech), v1), buf, j ? " (*)" : ""); vsi(buf2); } addline(); vsi("(*) / %ch%cgGreen%cn = Job already done. %ch%cyYellow%cn = To be done."); addline(); ShowCoolMenu(player, c); KillCoolMenu(c); }
char *damages_func(MECH * mech) { static char buffer[MBUF_SIZE]; int i; if (unit_is_fixable(mech)) make_damage_table(mech); else make_scrap_table(mech); buffer[0] = '\0'; if (!damage_last) return ""; for (i = 0; i < damage_last; i++) { /* Ok... i think we want: */ /* repairnum|location|typenum|data|fixing? */ if (i) sprintf(buffer, "%s,", buffer); sprintf(buffer, "%s%d|%s|%d|", buffer, i + 1, ShortArmorSectionString(MechType(mech), MechMove(mech), damage_table[i][1]), (int) damage_table[i][0]); switch (damage_table[i][0]) { case REPAIRP: case REPAIRP_T: case REPAIRG: case ENHCRIT_MISC: case ENHCRIT_FOCUS: case ENHCRIT_CRYSTAL: case ENHCRIT_BARREL: case ENHCRIT_AMMOB: case ENHCRIT_RANGING: case ENHCRIT_AMMOM: case SCRAPP: case SCRAPG: sprintf(buffer, "%s%s", buffer, pos_part_name(mech, damage_table[i][1], damage_table[i][2])); break; case RELOAD: sprintf(buffer, "%s%s:%d", buffer, pos_part_name(mech, damage_table[i][1], damage_table[i][2]), FullAmmo(mech, damage_table[i][1], damage_table[i][2]) - GetPartData(mech, damage_table[i][1], damage_table[i][2])); break; case UNLOAD: sprintf(buffer, "%s%s:%d", buffer, pos_part_name(mech, damage_table[i][1], damage_table[i][2]), GetPartData(mech, damage_table[i][1], damage_table[i] [2])); break; case FIXARMOR: case FIXARMOR_R: case FIXINTERNAL: sprintf(buffer, "%s%d", buffer, damage_table[i][2]); break; default: sprintf(buffer, "%s-", buffer); } sprintf(buffer, "%s|%d", buffer, is_under_repair(mech, i)); } return buffer; }
void showNetworkTargets(dbref player, MECH * mech, int tIsC3) { MAP *objMap = getMap(mech->mapindex); int i, j, wTemp, bearing; MECH *otherMech; float realRange, c3Range; char buff[100]; char *mech_name; char move_type[30]; char cStatus1, cStatus2, cStatus3, cStatus4, cStatus5; char weaponarc; int losFlag; int arc; int wSeeTarget = TARG_LOS_NONE; int wC3SeeTarget = TARG_LOS_NONE; int tShowStatusInfo = 0; char bufflist[MAX_MECHS_PER_MAP][120]; float rangelist[MAX_MECHS_PER_MAP]; int buffindex = 0; int sbuff[MAX_MECHS_PER_MAP]; int networkSize; dbref myNetwork[C3_NETWORK_SIZE]; dbref c3Ref; buildTempNetwork(mech, myNetwork, &networkSize, 1, 1, 0, tIsC3); /* * Send then a 'contacts' style report. This is different from the * normal contacts since it has a 'physical' range in it too. */ notify_printf(player, "%s Contacts:", tIsC3 ? "C3" : "C3i"); for(i = 0; i < objMap->first_free; i++) { if(!(objMap->mechsOnMap[i] != mech->mynum && objMap->mechsOnMap[i] != -1)) continue; otherMech = (MECH *) FindObjectsData(objMap->mechsOnMap[i]); if(!otherMech) continue; if(!Good_obj(otherMech->mynum)) continue; tShowStatusInfo = 0; realRange = FlMechRange(objMap, mech, otherMech); losFlag = InLineOfSight(mech, otherMech, MechX(otherMech), MechY(otherMech), realRange); /* * If we do see them, let's make sure it's not just a 'something' */ if(losFlag) { if(InLineOfSight_NB(mech, otherMech, MechX(otherMech), MechY(otherMech), 0.0)) wSeeTarget = TARG_LOS_CLEAR; else wSeeTarget = TARG_LOS_SOMETHING; } else wSeeTarget = TARG_LOS_NONE; /* * If I don't see it, let's see if someone else in the network does */ if(wSeeTarget != TARG_LOS_CLEAR) wC3SeeTarget = mechSeenByNetwork(mech, otherMech, tIsC3); /* If noone sees it, we continue */ if(!wSeeTarget && !wC3SeeTarget) continue; /* Get our network range */ c3Range = findC3RangeWithNetwork(mech, otherMech, realRange, myNetwork, networkSize, &c3Ref); /* Figure out if we show the info or not... ie, do we actually 'see' it */ if((wSeeTarget != TARG_LOS_CLEAR) && (wC3SeeTarget != TARG_LOS_CLEAR)) { tShowStatusInfo = 0; mech_name = "something"; } else { tShowStatusInfo = 1; mech_name = silly_atr_get(otherMech->mynum, A_MECHNAME); } bearing = FindBearing(MechFX(mech), MechFY(mech), MechFX(otherMech), MechFY(otherMech)); strcpy(move_type, GetMoveTypeID(MechMove(otherMech))); /* Get our weapon arc */ arc = InWeaponArc(mech, MechFX(otherMech), MechFY(otherMech)); weaponarc = getWeaponArc(mech, arc); /* Now get our status chars */ if(!tShowStatusInfo) { cStatus1 = ' '; cStatus2 = ' '; cStatus3 = ' '; cStatus4 = ' '; cStatus5 = ' '; } else { cStatus1 = getStatusChar(mech, otherMech, 1); cStatus2 = getStatusChar(mech, otherMech, 2); cStatus3 = getStatusChar(mech, otherMech, 3); cStatus4 = getStatusChar(mech, otherMech, 4); cStatus5 = getStatusChar(mech, otherMech, 5); } /* Now, build the string */ sprintf(buff, "%s%c%c%c[%s]%c %-11.11s x:%3d y:%3d z:%3d r:%4.1f c:%4.1f b:%3d s:%5.1f h:%3d S:%c%c%c%c%c%s", otherMech->mynum == MechTarget(mech) ? "%ch%cr" : (tShowStatusInfo && !MechSeemsFriend(mech, otherMech)) ? "%ch%cy" : "", (losFlag & MECHLOSFLAG_SEESP) ? 'P' : ' ', (losFlag & MECHLOSFLAG_SEESS) ? 'S' : ' ', weaponarc, MechIDS(otherMech, MechSeemsFriend(mech, otherMech) || !tShowStatusInfo), move_type[0], mech_name, MechX(otherMech), MechY(otherMech), MechZ(otherMech), realRange, c3Range, bearing, MechSpeed(otherMech), MechVFacing(otherMech), cStatus1, cStatus2, cStatus3, cStatus4, cStatus5, (otherMech->mynum == MechTarget(mech) || !MechSeemsFriend(mech, otherMech)) ? "%c" : ""); rangelist[buffindex] = realRange; rangelist[buffindex] += (MechStatus(otherMech) & DESTROYED) ? 10000 : 0; strcpy(bufflist[buffindex++], buff); } for(i = 0; i < buffindex; i++) sbuff[i] = i; /* print a sorted list of detected mechs */ /* use the ever-popular bubble sort */ for(i = 0; i < (buffindex - 1); i++) for(j = (i + 1); j < buffindex; j++) if(rangelist[sbuff[j]] > rangelist[sbuff[i]]) { wTemp = sbuff[i]; sbuff[i] = sbuff[j]; sbuff[j] = wTemp; } for(i = 0; i < buffindex; i++) notify(player, bufflist[sbuff[i]]); notify_printf(player, "End %s Contact List", tIsC3 ? "C3" : "C3i"); }