src/hcode/btech/mech.consistency.c

Go to the documentation of this file.
00001 /*
00002  * Author: Markus Stenberg <fingon@iki.fi>
00003  *
00004  *  Copyright (c) 1997 Markus Stenberg
00005  *       All rights reserved
00006  */
00007 
00008 #include "config.h"
00009 
00010 #include "mech.h"
00011 #include "coolmenu.h"
00012 #include "mycool.h"
00013 #include "p.mech.utils.h"
00014 #include "mech.partnames.h"
00015 #include <math.h>
00016 
00017 static char mech_loc_table[][2] = {
00018         {CTORSO, 1},
00019         {LTORSO, 2},
00020         {RTORSO, 2},
00021         {LARM, 3},
00022         {RARM, 3},
00023         {LLEG, 4},
00024         {RLEG, 4},
00025         {-1, 0}
00026 };
00027 
00028 static char quad_loc_table[][2] = {
00029         {CTORSO, 1},
00030         {LTORSO, 2},
00031         {RTORSO, 2},
00032         {LARM, 4},
00033         {RARM, 4},
00034         {LLEG, 4},
00035         {RLEG, 4},
00036         {-1, 0}
00037 };
00038 
00039 static char int_data[][5] = {
00040         {10, 4, 3, 1, 2},
00041         {15, 5, 4, 2, 3},
00042         {20, 6, 5, 3, 4},
00043         {25, 8, 6, 4, 6},
00044         {30, 10, 7, 5, 7},
00045         {35, 11, 8, 6, 8},
00046         {40, 12, 10, 6, 10},
00047         {45, 14, 11, 7, 11},
00048         {50, 16, 12, 8, 12},
00049         {55, 18, 13, 9, 13},
00050         {60, 20, 14, 10, 14},
00051         {65, 21, 15, 10, 15},
00052         {70, 22, 15, 11, 15},
00053         {75, 23, 16, 12, 16},
00054         {80, 25, 17, 13, 17},
00055         {85, 27, 18, 14, 18},
00056         {90, 29, 19, 15, 19},
00057         {95, 30, 20, 16, 20},
00058         {100, 31, 21, 17, 21},
00059         {-1, 0, 0, 0, 0}
00060 };
00061 
00062 static short engine_data[][2] = {
00063         {0, 0},
00064         {10, 1},
00065         {15, 1},
00066         {20, 1},
00067         {25, 1},
00068         {30, 2},
00069         {35, 2},
00070         {40, 2},
00071         {45, 2},
00072         {50, 3},
00073         {55, 3},
00074         {60, 3},
00075         {65, 4},
00076         {70, 4},
00077         {75, 4},
00078         {80, 5},
00079         {85, 5},
00080         {90, 6},
00081         {95, 6},
00082         {100, 6},
00083         {105, 7},
00084         {110, 7},
00085         {115, 8},
00086         {120, 8},
00087         {125, 8},
00088         {130, 9},
00089         {135, 9},
00090         {140, 10},
00091         {145, 10},
00092         {150, 11},
00093         {155, 11},
00094         {160, 12},
00095         {165, 12},
00096         {170, 12},
00097         {175, 14},
00098         {180, 14},
00099         {185, 15},
00100         {190, 15},
00101         {195, 16},
00102         {200, 17},
00103         {205, 17},
00104         {210, 18},
00105         {215, 19},
00106         {220, 20},
00107         {225, 20},
00108         {230, 21},
00109         {235, 22},
00110         {240, 23},
00111         {245, 24},
00112         {250, 25},
00113         {255, 26},
00114         {260, 27},
00115         {265, 28},
00116         {270, 29},
00117         {275, 31},
00118         {280, 32},
00119         {285, 33},
00120         {290, 35},
00121         {295, 36},
00122         {300, 38},
00123         {305, 39},
00124         {310, 41},
00125         {315, 43},
00126         {320, 45},
00127         {325, 47},
00128         {330, 49},
00129         {335, 51},
00130         {340, 54},
00131         {345, 57},
00132         {350, 59},
00133         {355, 63},
00134         {360, 66},
00135         {365, 69},
00136         {370, 73},
00137         {375, 77},
00138         {380, 82},
00139         {385, 87},
00140         {390, 92},
00141         {395, 98},
00142         {400, 105},
00143         {405, 113},
00144         {410, 122},
00145         {415, 133},
00146         {420, 145},
00147         {425, 159},
00148         {430, 87 * 2 + 1},
00149         {435, 97 * 2},
00150         {440, 107 * 2 + 1},
00151         {445, 119 * 2 + 1},
00152         {450, 133 * 2 + 1},
00153         {455, 150 * 2},
00154         {460, 168 * 2 + 1},
00155         {465, 190 * 2},
00156         {470, 214 * 2 + 1},
00157         {475, 243 * 2},
00158         {480, 275 * 2 + 1},
00159         {485, 313 * 2},
00160         {490, 356 * 2},
00161         {495, 405 * 2 + 1},
00162         {500, 462 * 2 + 1},
00163         {-1, 0}
00164 };
00165 
00166 int susp_factor(MECH * mech)
00167 {
00168         int t = MechTons(mech);
00169 
00170         if(MechMove(mech) == MOVE_TRACK)
00171                 return 0;
00172         if(MechMove(mech) == MOVE_WHEEL)
00173                 return 20;
00174 #define MAP(a,b) if (t <= a) return b
00175         if(MechMove(mech) == MOVE_FOIL) {
00176                 MAP(10, 60);
00177                 MAP(20, 105);
00178                 MAP(30, 150);
00179                 MAP(40, 195);
00180                 MAP(50, 255);
00181                 MAP(60, 300);
00182                 MAP(70, 345);
00183                 MAP(80, 390);
00184                 MAP(90, 435);
00185                 return 480;
00186         }
00187         if(MechMove(mech) == MOVE_HOVER) {
00188                 MAP(10, 40);
00189                 MAP(20, 85);
00190                 MAP(30, 130);
00191                 MAP(40, 175);
00192                 return 235;
00193         }
00194         if(MechMove(mech) == MOVE_HULL || MechMove(mech) == MOVE_SUB)
00195                 return 30;
00196         if(MechMove(mech) == MOVE_VTOL) {
00197                 MAP(10, 50);
00198                 MAP(20, 95);
00199                 return 140;
00200         }
00201         return 0;
00202 }
00203 
00204 static int round_to_halfton(int weight)
00205 {
00206         int over = weight % 512;
00207         if(!over)
00208                 return weight;
00209         if(over < 2)
00210                 return weight - over;
00211         return weight + (512 - over);
00212 }
00213 
00214 int crit_weight(MECH * mech, int t)
00215 {
00216         int cl;
00217 
00218         if(IsWeapon(t))
00219                 return MechWeapons[Weapon2I(t)].weight * 1024 / 100 /
00220                         GetWeaponCrits(mech, Weapon2I(t));
00221         if(IsAmmo(t))
00222                 return 512;
00223         if(!(IsSpecial(t)))
00224                 return 1024;
00225 
00226         t = Special2I(t);
00227         cl = MechSpecials(mech) & CLAN_TECH;
00228 
00229         switch (t) {
00230         case HEAT_SINK:
00231                 return 1024 / HS_Size(mech);
00232         case TARGETING_COMPUTER:
00233         case AXE:
00234         case MACE:
00235                 return 1024;
00236         case DUAL_SAW:
00237                 return 1024;
00238         case ARTEMIS_IV:
00239         case MASC:
00240         case C3_SLAVE:
00241         case TAG:
00242         case LAMEQUIP:
00243                 return 1024;
00244         case C3I:
00245                 return 1280 * (MechType(mech) == CLASS_MECH ? 1 : 2);
00246         case ANGELECM:
00247         case BLOODHOUND_PROBE:
00248                 return 1024 * (MechType(mech) == CLASS_MECH ? 1 : 2);
00249         case C3_MASTER:
00250                 return 1024 * (MechType(mech) == CLASS_MECH ? 1 : 5);
00251         case SWORD:
00252                 /* A Sword weighs 1/20th of the 'mech tonnage, rounded up to the half
00253                    ton, and is 1/15th (rounded up to int) number of crits. */
00254                 return (ceil(MechTons(mech) / 10.) * 512) /
00255                         (ceil(MechTons(mech) / 15.));
00256         case BEAGLE_PROBE:
00257                 return 1024 * 3 / (MechType(mech) == CLASS_MECH ? 4 : 2);
00258         case ECM:
00259                 /* IS ECM is 1.5 tons for 2 crits, Clan ECM 1 ton for 1 crit. */
00260                 return 1024 * (cl ? 4 : MechType(mech) == CLASS_MECH ? 3 : 6) / 4;
00261         case CASE:
00262                 return 512;
00263         case JUMP_JET:
00264                 if(MechTons(mech) <= 55)
00265                         return 512;
00266                 if(MechTons(mech) <= 85)
00267                         return 1024;
00268                 return 2048;
00269         default:
00270                 return 0;
00271         }
00272 }
00273 
00274 static int engine_weight(MECH * mech)
00275 {
00276         int s = MechEngineSize(mech);
00277         int i;
00278 
00279         if(MechType(mech) != CLASS_MECH)
00280                 s -= susp_factor(mech);
00281 
00282         for(i = 0; engine_data[i][0] >= 0; i++)
00283                 if(s == engine_data[i][0]) {
00284                         int weight = engine_data[i][1] * 512;
00285 
00286                         if(MechSpecials(mech) & ICE_TECH)
00287                                 return weight * 2;
00288 
00289                         if(MechType(mech) == CLASS_VEH_GROUND ||
00290                            MechType(mech) == CLASS_VTOL ||
00291                            MechType(mech) == CLASS_VEH_NAVAL)
00292                                 /* Vehicles need extra shielding in case of a fusion engine */
00293                                 weight = round_to_halfton(weight + weight / 2);
00294 
00295                         if(MechSpecials(mech) & XL_TECH)
00296                                 return round_to_halfton(weight / 2);
00297 
00298                         if(MechSpecials(mech) & XXL_TECH)
00299                                 return round_to_halfton(weight / 3);
00300 
00301                         if(MechSpecials(mech) & LE_TECH)
00302                                 return round_to_halfton(weight * 3 / 4);
00303 
00304                         if(MechSpecials(mech) & CE_TECH)
00305                                 return round_to_halfton(weight + weight / 2);
00306 
00307                         return weight;
00308                 }
00309 
00310         SendError(tprintf("Error in #%d (%s) : No engine found!", mech->mynum,
00311                                           Name(mech->mynum)));
00312         return 0;
00313 }
00314 
00315 static void calc_ints(MECH * mech, int *n, int *tot)
00316 {
00317         int i;
00318 
00319         *n = 0;
00320         *tot = 0;
00321         for(i = 0; i < NUM_SECTIONS; i++) {
00322                 *n += GetSectInt(mech, i);
00323                 *tot += GetSectOInt(mech, i);
00324         }
00325         *tot = MAX(1, *tot);
00326 }
00327 
00328 static int ammo_weight(MECH * mech)
00329 {
00330         int i, j, t, w = 0;
00331 
00332         for(i = 0; i < NUM_SECTIONS; i++)
00333                 if(!SectIsDestroyed(mech, i))
00334                         for(j = 0; j < CritsInLoc(mech, i); j++)
00335                                 if(IsAmmo((t = GetPartType(mech, i, j))))
00336                                         w += GetPartData(mech, i,
00337                                                                          j) * 1024 /
00338                                                 MechWeapons[Ammo2I(GetPartType(mech, i, j))].
00339                                                 ammoperton;
00340         return w;
00341 }
00342 
00343 #define MyGetSectOArmor(m,l) (interactive>=0?GetSectOArmor(m,l):GetSectArmor(m,l))
00344 #define MyGetSectORArmor(m,l) (interactive>=0?GetSectORArmor(m,l):GetSectRArmor(m,l))
00345 #define PLOC(a) if (interactive >= 0 || !SectIsDestroyed(mech,a))
00346 #define MyMechNumOsinks(m) ((interactive >= 0) ? (MechNumOsinks(m)) : (MechRealNumsinks(m)))
00347 int mech_weight_sub_mech(dbref player, MECH * mech, int interactive)
00348 {
00349         int pile[NUM_ITEMS_M];
00350         int i, j, w, cl, id;
00351         int armor = 0, armor_o;
00352         int total = 0;
00353         coolmenu *c = NULL;
00354         int shs_size;
00355         int hs_eff;
00356         char buf[MBUF_SIZE];
00357         int ints_c, ints_tot;
00358         float gyro_calc = -1;
00359 
00360         bzero(pile, sizeof(pile));
00361         if(interactive > 0) {
00362                 addline();
00363                 cent(tprintf("Weight totals for %s", GetMechID(mech)));
00364                 addline();
00365         }
00366         calc_ints(mech, &ints_c, &ints_tot);
00367         for(i = 0; i < NUM_SECTIONS; i++) {
00368                 if(!GetSectOInt(mech, i))
00369                         continue;
00370                 armor += MyGetSectOArmor(mech, i);
00371                 armor += MyGetSectORArmor(mech, i);
00372                 PLOC(i)
00373                         for(j = 0; j < NUM_CRITICALS; j++)
00374                         if(interactive >= 0 || !IsAmmo(GetPartType(mech, i, j)))
00375                                 pile[GetPartType(mech, i, j)] += AmmoMod(mech, i, j);
00376         }
00377         shs_size = HS_Size(mech);
00378         hs_eff = HS_Efficiency(mech);
00379         cl = MechSpecials(mech) & CLAN_TECH;
00380 #define ADDENTRY(text,weight) \
00381     if (weight) { if (interactive>0) { addmenu(text);addmenu(tprintf("      %6.1f", (float) (weight) / 1024.0));}; total += weight; }
00382 #define ADDENTRY_C(text,count,weight) \
00383     if (weight) { if (interactive>0) { addmenu(text);addmenu(tprintf("%5d %6.1f", count, (float) (weight) / 1024.0)); }; total += weight; }
00384         sprintf(buf, "%-12s(%d rating)",
00385                         MechSpecials(mech) & XL_TECH ? "Engine (XL)" : MechSpecials(mech)
00386                         & XXL_TECH ? "Engine (XXL)" : MechSpecials(mech) & CE_TECH ?
00387                         "Engine (Compact)" : MechSpecials(mech) & LE_TECH ?
00388                         "Engine (Light)" : "Engine", MechEngineSize(mech));
00389         PLOC(CTORSO)
00390                 ADDENTRY(buf, engine_weight(mech));
00391         PLOC(HEAD)
00392                 ADDENTRY("Cockpit", 3 * 1024);
00393         PLOC(CTORSO)
00394                 /* Store the base-line gyro weight */
00395                 gyro_calc = (MechEngineSize(mech) / 100.0) * 1024;
00396 
00397         /* Figure out what kind of gyro we have and adjust weight accordingly */
00398         if(MechSpecials2(mech) & XLGYRO_TECH) {
00399                 /* XL Gyro is 1/2 normal gyro weight. */
00400                 ADDENTRY("Gyro (XL)", (int) ceil(gyro_calc * 0.5));
00401         } else if(MechSpecials2(mech) & HDGYRO_TECH) {
00402                 /* Hardened Gyro is 2x normal gyro weight. */
00403                 ADDENTRY("Gyro (Hardened)", (int) ceil(gyro_calc * 2));
00404         } else if(MechSpecials2(mech) & CGYRO_TECH) {
00405                 /* Compact Gyro is 1.5x normal gyro weight. */
00406                 ADDENTRY("Gyro (Compact)", (int) ceil(gyro_calc * 1.5));
00407         } else {
00408                 /* Standard Gyro. */
00409                 ADDENTRY("Gyro", (int) ceil(gyro_calc));
00410         }
00411 
00412         ADDENTRY(MechSpecials(mech) & REINFI_TECH ? "Internals (Reinforced)" :
00413                          MechSpecials(mech) & COMPI_TECH ? "Internals (Composite)" :
00414                          MechSpecials(mech) & ES_TECH ? "Internals (ES)" : "Internals",
00415                          round_to_halfton(MechTons(mech) * 1024 * (interactive >=
00416                                                                                                            0 ? ints_tot : ints_c)
00417                                                           / 5 / ints_tot /
00418                                                           (MechSpecials(mech) & REINFI_TECH ? 1
00419                                                            : (MechSpecials(mech) & (ES_TECH | COMPI_TECH))
00420                                                            ? 4 : 2)));
00421         armor_o = armor;
00422         if(MechSpecials(mech) & FF_TECH)
00423                 armor = armor * 50 / (cl ? 60 : 56);
00424         else if(MechSpecials2(mech) & HVY_FF_ARMOR_TECH)
00425                 armor = armor * 50 / 62;
00426         else if(MechSpecials2(mech) & LT_FF_ARMOR_TECH)
00427                 armor = armor * 50 / 53;
00428 
00429         ADDENTRY_C(MechSpecials2(mech) & STEALTH_ARMOR_TECH ? "Armor (Stealth)"
00430                            : MechSpecials2(mech) & HVY_FF_ARMOR_TECH ? "Armor (Hvy FF)" :
00431                            MechSpecials2(mech) & LT_FF_ARMOR_TECH ? "Armor (Lt FF)" :
00432                            MechSpecials(mech) & HARDA_TECH ? "Armor (Hardened)" :
00433                            MechSpecials(mech) & FF_TECH ? "Armor (FF)" : "Armor", armor_o,
00434                            ceil(armor /
00435                                         (8. * (MechSpecials(mech) & HARDA_TECH ? 2 : 1))) * 512);
00436 
00437         if(MyMechNumOsinks(mech)) {
00438                 pile[Special(HEAT_SINK)] =
00439                         MAX(0, MyMechNumOsinks(mech) * shs_size / hs_eff -
00440                                 (MechSpecials(mech) & ICE_TECH ? 0 : 10) * shs_size);
00441         } else if(interactive > 0)
00442                 cent(tprintf
00443                          ("WARNING: HS count may be off, due to certain odd things."));
00444         for(i = 1; i < NUM_ITEMS_M; i++)
00445                 if(pile[i]) {
00446                         if(IsWeapon(i)) {
00447                                 id = Weapon2I(i);
00448                                 ADDENTRY_C(MechWeapons[id].name,
00449                                                    pile[i] / GetWeaponCrits(mech, id),
00450                                                    crit_weight(mech, i) * pile[i]);
00451                         } else {
00452                                 if((w = crit_weight(mech, i)))
00453                                         ADDENTRY_C(get_parts_long_name(i, 0), pile[i],
00454                                                            w * pile[i]);
00455                         }
00456                 }
00457         if(CargoSpace(mech))
00458                 ADDENTRY(tprintf
00459                                  ("CargoSpace (%.2ft)", (float) CargoSpace(mech) / 100),
00460                                  (int) (((float) CargoSpace(mech) /
00461                                                  (MechSpecials2(mech) & CARRIER_TECH ? 1000 :
00462                                                   MechSpecials(mech) & CARGO_TECH ? 100 : 500)) *
00463                                                 1024));
00464 
00465         if(interactive > 0) {
00466                 addline();
00467                 vsi(tprintf("%%cgTotal: %s%.1f tons (offset: %.1f)%%cn",
00468                                         (total / 1024) > MechTons(mech) ? "%ch%cr" : "",
00469                                         (float) (total) / 1024.0,
00470                                         MechTons(mech) - (float) (total) / 1024.0));
00471                 addline();
00472                 ShowCoolMenu(player, c);
00473         }
00474         KillCoolMenu(c);
00475         if(interactive < 0)
00476                 total += ammo_weight(mech);
00477         return MAX(1, total);
00478 }
00479 
00480 static int tank_in_pieces(MECH * mech)
00481 {
00482         int i;
00483 
00484         for(i = 0; i < NUM_SECTIONS; i++)
00485                 if(GetSectInt(mech, i))
00486                         return 0;
00487         return 1;
00488 }
00489 
00490 int mech_weight_sub_veh(dbref player, MECH * mech, int interactive)
00491 {
00492         int pile[NUM_ITEMS_M];
00493         int i, j, w, cl, id, t;
00494         int armor = 0, armor_o;
00495         int total = 0;
00496         coolmenu *c = NULL;
00497         int shs_size;
00498         int hs_eff;
00499         char buf[MBUF_SIZE];
00500         int es;
00501         int turr_stuff = 0;
00502         int ints_c, ints_tot;
00503 
00504         bzero(pile, sizeof(pile));
00505         calc_ints(mech, &ints_c, &ints_tot);
00506         if(interactive > 0) {
00507                 addline();
00508                 cent(tprintf("Weight totals for %s", GetMechID(mech)));
00509                 addline();
00510         }
00511         for(i = 0; i < NUM_SECTIONS; i++) {
00512                 if(!(GetSectOInt(mech, i)))
00513                         continue;
00514                 armor += MyGetSectOArmor(mech, i);
00515                 armor += MyGetSectORArmor(mech, i);
00516                 for(j = 0; j < CritsInLoc(mech, i); j++) {
00517                         if(!(t = GetPartType(mech, i, j)))
00518                                 continue;
00519                         if(interactive >= 0 || !SectIsDestroyed(mech, i)) {
00520                                 if(interactive >= 0 || !IsAmmo(t))
00521                                         pile[t] += AmmoMod(mech, i, j);
00522                                 if(i == TURRET && (MechType(mech) == CLASS_VEH_GROUND ||
00523                                                                    MechType(mech) == CLASS_VEH_NAVAL))
00524                                         if(IsWeapon(t))
00525                                                 turr_stuff += crit_weight(mech, t);
00526                         }
00527                 }
00528         }
00529         shs_size = HS_Size(mech);
00530         hs_eff = HS_Efficiency(mech);
00531         cl = MechSpecials(mech) & CLAN_TECH;
00532         es = susp_factor(mech);
00533         if(es)
00534                 sprintf(buf, "%-12s(%d->%d eff/wt rat)",
00535                                 MechSpecials(mech) & LE_TECH ? "Engine (Light)" :
00536                                 MechSpecials(mech) & CE_TECH ? "Engine (Compact)" :
00537                                 MechSpecials(mech) & XXL_TECH ? "Engine (XXL)" :
00538                                 MechSpecials(mech) & XL_TECH ? "Engine (XL)" :
00539                                 MechSpecials(mech) & ICE_TECH ? "Engine (ICE)" : "Engine",
00540                                 MechEngineSize(mech),
00541                                 MechEngineSize(mech) - susp_factor(mech));
00542         else
00543                 sprintf(buf, "%-12s(%d rating)",
00544                                 MechSpecials(mech) & LE_TECH ? "Engine (Light)" :
00545                                 MechSpecials(mech) & CE_TECH ? "Engine (Compact)" :
00546                                 MechSpecials(mech) & XXL_TECH ? "Engine (XXL)" :
00547                                 MechSpecials(mech) & XL_TECH ? "Engine (XL)" :
00548                                 MechSpecials(mech) & ICE_TECH ? "Engine (ICE)" : "Engine",
00549                                 MechEngineSize(mech));
00550         if(!tank_in_pieces(mech)) {
00551                 ADDENTRY(buf, (es = engine_weight(mech)));
00552                 if(MechMove(mech) == MOVE_HOVER && es < (MechTons(mech) * 1024 / 5))
00553                         ADDENTRY("Engine size fix (-> 1/5 hover wt.)",
00554                                          MechTons(mech) * 1024 / 5 - es);
00555                 ADDENTRY("Cockpit", round_to_halfton(MechTons(mech) * 1024 / 20));
00556                 if(MechType(mech) == CLASS_VTOL ||
00557                    MechMove(mech) == MOVE_HOVER || MechMove(mech) == MOVE_HULL ||
00558                    MechMove(mech) == MOVE_SUB)
00559                         ADDENTRY("SpecialComponents",
00560                                          round_to_halfton(MechTons(mech) * 1024 / 10));
00561         }
00562         PLOC(TURRET)
00563                 if(turr_stuff)
00564                 ADDENTRY("Turret", round_to_halfton(turr_stuff / 10));
00565         ADDENTRY(MechSpecials(mech) & REINFI_TECH ? "Internals (Reinforced)" :
00566                          MechSpecials(mech) & COMPI_TECH ? "Internals (Composite)" :
00567                          MechSpecials(mech) & ES_TECH ? "Internals (ES)" : "Internals",
00568                          round_to_halfton(MechTons(mech) * 1024 * (interactive >=
00569                                                                                                            0 ? ints_tot : ints_c)
00570                                                           / 5 / ints_tot /
00571                                                           (MechSpecials(mech) & REINFI_TECH ? 1
00572                                                            : (MechSpecials(mech) & (ES_TECH | COMPI_TECH))
00573                                                            ? 4 : 2)));
00574         armor_o = armor;
00575 
00576         if(MechSpecials(mech) & FF_TECH)
00577                 armor = armor * 50 / (cl ? 60 : 56);
00578         else if(MechSpecials2(mech) & HVY_FF_ARMOR_TECH)
00579                 armor = armor * 50 / 62;
00580         else if(MechSpecials2(mech) & LT_FF_ARMOR_TECH)
00581                 armor = armor * 50 / 53;
00582         else if(MechSpecials(mech) & HARDA_TECH)
00583                 armor *= 2;
00584 
00585         ADDENTRY_C(MechSpecials2(mech) & STEALTH_ARMOR_TECH ? "Armor (Stealth)"
00586                            : MechSpecials2(mech) & HVY_FF_ARMOR_TECH ? "Armor (Hvy FF)" :
00587                            MechSpecials2(mech) & LT_FF_ARMOR_TECH ? "Armor (Lt FF)" :
00588                            MechSpecials(mech) & HARDA_TECH ? "Armor (Hardened)" :
00589                            MechSpecials(mech) & FF_TECH ? "Armor (FF)" : "Armor", armor_o,
00590                            round_to_halfton(armor * 1024 / 16));
00591 
00592         pile[Special(HEAT_SINK)] =
00593                 MAX(0, MechRealNumsinks(mech) * shs_size / hs_eff -
00594                         (MechSpecials(mech) & ICE_TECH ? 0 : 10) * shs_size);
00595         for(i = 1; i < NUM_ITEMS_M; i++)
00596                 if(pile[i]) {
00597                         if(IsWeapon(i)) {
00598                                 id = Weapon2I(i);
00599                                 ADDENTRY_C(MechWeapons[id].name,
00600                                                    pile[i] / GetWeaponCrits(mech, id),
00601                                                    crit_weight(mech, i) * pile[i]);
00602                         } else if((w = crit_weight(mech, i)))
00603                                 ADDENTRY_C(get_parts_long_name(i, 0), pile[i], w * pile[i]);
00604                 }
00605         if(CargoSpace(mech))
00606                 ADDENTRY(tprintf
00607                                  ("CargoSpace (%.2ft)", (float) CargoSpace(mech) / 100),
00608                                  (int) (((float) CargoSpace(mech) /
00609                                                  (MechSpecials2(mech) & CARRIER_TECH ? 1000 :
00610                                                   MechSpecials(mech) & CARGO_TECH ? 100 : 500)) *
00611                                                 1024));
00612 
00613         if(interactive > 0) {
00614                 addline();
00615                 vsi(tprintf("%%cgTotal: %s%.1f tons (offset: %.1f)%%cn",
00616                                         (total / 1024) > MechTons(mech) ? "%ch%cr" : "",
00617                                         (float) (total) / 1024.0,
00618                                         MechTons(mech) - (float) (total) / 1024.0));
00619                 addline();
00620                 ShowCoolMenu(player, c);
00621         }
00622         KillCoolMenu(c);
00623         if(interactive < 0)
00624                 total += ammo_weight(mech);
00625         return MAX(1, total);
00626 }
00627 
00628 /* Returns: 1024 * MechWeight(in tons) */
00629 int mech_weight_sub(dbref player, MECH * mech, int interactive)
00630 {
00631         if(MechType(mech) == CLASS_MECH)
00632                 return mech_weight_sub_mech(player, mech, interactive);
00633         if(MechType(mech) == CLASS_VEH_GROUND ||
00634            MechType(mech) == CLASS_VTOL || MechType(mech) == CLASS_VEH_NAVAL)
00635                 return mech_weight_sub_veh(player, mech, interactive);
00636         if(interactive > 0)
00637                 notify(player, "Invalid vehicle type!");
00638         return 1;
00639 }
00640 
00641 void mech_weight(dbref player, void *data, char *buffer)
00642 {
00643         MECH *mech = (MECH *) data;
00644 
00645         mech_weight_sub(player, mech, 1);
00646 }
00647 
00648 #define Table(i,j) \
00649 (MechIsQuad(mech) ? quad_loc_table[i][j] : mech_loc_table[i][j])
00650 
00651 static int real_int(MECH * mech, int loc, int ti)
00652 {
00653         int i;
00654 
00655         if(loc == HEAD)
00656                 return 3;
00657         for(i = 0; Table(i, 0) >= 0; i++)
00658                 if(loc == Table(i, 0))
00659                         break;
00660         if(Table(i, 0) < 0)
00661                 return 0;
00662         return int_data[ti][Table(i, 1)];
00663 }
00664 
00665 #define tank_int(mech)  MAX((MechTons(mech) + 5) / 10, 1)
00666 
00667 void vehicle_int_check(MECH * mech, int noisy)
00668 {
00669         int i, j;
00670 
00671         j = tank_int(mech);
00672         for(i = 0; i < NUM_SECTIONS; i++)
00673                 if(GetSectOInt(mech, i) && GetSectOInt(mech, i) != j) {
00674                         if(noisy)
00675                                 SendError(tprintf
00676                                                   ("Template %s / mech #%d: Invalid internals in loc %d (should be %d, are %d)",
00677                                                    MechType_Ref(mech), mech->mynum, i, j,
00678                                                    GetSectOInt(mech, i)));
00679                         SetSectOInt(mech, i, j);
00680                         SetSectInt(mech, i, j);
00681                 }
00682 }
00683 
00684 void mech_int_check(MECH * mech, int noisy)
00685 {
00686         int i, j, k;
00687 
00688         if(MechType(mech) != CLASS_MECH) {
00689                 if(MechType(mech) == CLASS_VEH_GROUND ||
00690                    MechType(mech) == CLASS_VTOL || MechType(mech) == CLASS_VEH_NAVAL)
00691                         vehicle_int_check(mech, noisy);
00692                 return;
00693         }
00694         for(i = 0; int_data[i][0] >= 0; i++)
00695                 if(MechTons(mech) == int_data[i][0])
00696                         break;
00697         if(int_data[i][0] < 0) {
00698                 if(noisy)
00699                         SendError(tprintf("VERY odd tonnage for #%d: %d.", mech->mynum,
00700                                                           MechTons(mech)));
00701                 return;
00702         }
00703         k = i;
00704         for(i = 0; i < NUM_SECTIONS; i++) {
00705                 if(GetSectOInt(mech, i) != (j = real_int(mech, i, k))) {
00706                         if(noisy)
00707                                 SendError(tprintf
00708                                                   ("Template %s / mech #%d: Invalid internals in loc %d (should be %d, are %d)",
00709                                                    MechType_Ref(mech), mech->mynum, i, j,
00710                                                    GetSectOInt(mech, i)));
00711                         SetSectOInt(mech, i, j);
00712                         SetSectInt(mech, i, j);
00713                 }
00714         }
00715 }

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