src/hcode/btech/p.map.weather.h File Reference

Go to the source code of this file.

Functions

int validateWeatherConditions (int curConditions)
int calcWeatherEffects (MAP *map)
int calcWeatherGunEffects (MAP *map, int weapindx)
int calcWeatherPilotEffects (MECH *mech)
void setWeatherHeatEffects (MAP *map, MECH *mech)
void meltSnowAndIce (MAP *map, int x, int y, int depth, int emit, int makeSteam)
void growSnow (MAP *map, int lowDepth, int highDepth)


Function Documentation

int calcWeatherEffects ( MAP map  ) 

Definition at line 28 of file map.weather.c.

References MAP::temp, and MAP::windspeed.

00029 {
00030         int effects = 0;
00031         int weather = map->weather;
00032         char temp = map->temp;
00033         short windspeed = map->windspeed;
00034 
00035         if(windspeed > 60)
00036                 effects = EFFECT_HIGH_WINDS;
00037         else if(windspeed >= 30)
00038                 effects = EFFECT_WINDS;
00039 
00040         if(weather & WEATHER_HEAVY_PRECIP) {
00041                 if(temp <= 0) {
00042                         if(effects & EFFECT_HIGH_WINDS) {
00043                                 effects &= ~EFFECT_HIGH_WINDS;
00044                                 effects |= EFFECT_BLIZZARD;
00045                         } else
00046                                 effects |= EFFECT_HEAVY_SNOW;
00047                 } else
00048                         effects |= EFFECT_HEAVY_RAIN;
00049         } else if(weather & WEATHER_PRECIP) {
00050                 if(temp <= 0)
00051                         effects |= EFFECT_SNOW;
00052                 else
00053                         effects |= EFFECT_RAIN;
00054         }
00055 
00056         if(weather & WEATHER_FOG)
00057                 effects |= EFFECT_FOG;
00058 
00059         if(weather & WEATHER_BLOWING_SAND)
00060                 effects |= EFFECT_BLOWING_SAND;
00061 
00062         return effects;
00063 }

int calcWeatherGunEffects ( MAP map,
int  weapindx 
)

Definition at line 65 of file map.weather.c.

References MechWeapons, TAMMO, TBEAM, and weapon_struct::type.

00066 {
00067         int gunMods = 0;
00068         int weapType = MechWeapons[weapindx].type;
00069 
00070         if(MapEffectRain(map)) {
00071                 gunMods += 1;
00072         } else if(MapEffectRain(map)) {
00073                 gunMods += 1;
00074         }
00075 
00076         if(MapEffectBlizzard(map)) {
00077                 gunMods += ((weapType == TAMMO) ? 2 : 1);
00078         } else if(MapEffectHvySnow(map)) {
00079                 gunMods += 1;
00080         }
00081 
00082         if(MapEffectFog(map)) {
00083                 gunMods += ((weapType == TBEAM) ? 1 : 0);
00084         }
00085 
00086         if(MapEffectSand(map)) {
00087                 gunMods += ((weapType == TAMMO) ? 1 : 2);
00088         }
00089 
00090         if(MapEffectHighWinds(map) & !MapEffectBlizzard(map)) {
00091                 gunMods += ((weapType == TAMMO) ? 2 : 0);
00092         }
00093 
00094         if(MapEffectWinds(map)) {
00095                 gunMods += ((weapType == TAMMO) ? 1 : 0);
00096         }
00097 
00098         return gunMods;
00099 }

int calcWeatherPilotEffects ( MECH mech  ) 

Definition at line 101 of file map.weather.c.

References Elevation, FindObjectsData(), Jumping, MECH::mapindex, MechMove, MechX, MechY, MechZ, and MOVE_HOVER.

00102 {
00103         MAP *map = FindObjectsData(mech->mapindex);
00104         int onTheGround = 1;
00105         int mod = 0;
00106 
00107         if(!map)
00108                 return 0;
00109 
00110         onTheGround = (!Jumping(mech) &&
00111                                    (MechZ(mech) <= Elevation(map, MechX(mech), MechY(mech))));
00112 
00113         if(onTheGround) {
00114                 if((MapEffectHvyRain(map) || MapEffectHvySnow(map) ||
00115                         MapEffectHighWinds(map) || MapEffectBlizzard(map)))
00116                         mod += 1;
00117 
00118                 if(MechMove(mech) != MOVE_HOVER) {
00119                         if(HexHasDeepSnow(map, MechX(mech), MechY(mech)))
00120                                 mod += 1;
00121 
00122                         if(HexHasMud(map, MechX(mech), MechY(mech)))
00123                                 mod += 1;
00124 
00125                         if(HexHasRapids(map, MechX(mech), MechY(mech)))
00126                                 mod += 2;
00127                 }
00128 
00129                 return mod;
00130         }
00131 
00132         return 0;
00133 }

void growSnow ( MAP map,
int  lowDepth,
int  highDepth 
)

Definition at line 234 of file map.weather.c.

References BRIDGE, FIRE, GetHexLayerData(), GetHexTerrain(), ICE, MAP::map_height, MAP::map_width, MAX, MIN, Number, SetHexLayerData(), SetHexLayers(), sign(), validateSnowDepth(), and WATER.

00235 {
00236         int i, j;
00237         char terrain;
00238         int layer, layerData;
00239         int depth = 0;
00240         int sign = 1;
00241         int low, high;
00242 
00243         if((lowDepth == 0) && (highDepth == 0))
00244                 return;
00245 
00246         low = MIN(abs(lowDepth), abs(highDepth));
00247         high = MAX(abs(lowDepth), abs(highDepth));
00248 
00249         if((lowDepth < 0) || (highDepth < 0))
00250                 sign = -1;
00251 
00252         for(i = 0; i < map->map_width; i++) {
00253                 for(j = 0; j < map->map_height; j++) {
00254                         terrain = GetHexTerrain(map, i, j);
00255 
00256                         switch (terrain) {
00257                         case BRIDGE:
00258                         case FIRE:
00259                         case WATER:
00260                         case ICE:
00261                                 continue;
00262                                 break;
00263                         }
00264 
00265                         depth = Number(low, high) * sign;
00266 
00267                         if(depth == 0)
00268                                 continue;
00269 
00270                         layerData = GetHexLayerData(map, i, j);
00271 
00272                         if(depth < 0) {
00273                                 if(!(HexHasSnow(map, i, j) || HexHasDeepSnow(map, i, j)))
00274                                         continue;
00275                         } else {
00276                                 if(!(HexHasSnow(map, i, j) && HexHasDeepSnow(map, i, j)))
00277                                         SetHexLayers(map, i, j, HEXLAYER_SNOW);
00278                         }
00279 
00280                         SetHexLayerData(map, i, j, (layerData + depth));
00281                         validateSnowDepth(map, i, j);
00282                 }
00283         }
00284 
00285 }

void meltSnowAndIce ( MAP map,
int  x,
int  y,
int  depth,
int  emit,
int  makeSteam 
)

Definition at line 160 of file map.weather.c.

References add_decoration(), Elevation, GetHexLayerData(), GetHexLayers(), HexLOSBroadcast(), MAX, Number, SetHexLayerData(), SetHexLayers(), SMOKE, and TYPE_SMOKE.

00162 {
00163         int data = 0;
00164         int layers = 0, oldLayers = 0;
00165         int snowDone = 0;
00166         int steamLength = 0;
00167 
00168         if(!map)
00169                 return;
00170 
00171         if(depth <= 0)
00172                 return;
00173 
00174         oldLayers = GetHexLayers(map, x, y);
00175         layers = oldLayers;
00176         data = GetHexLayerData(map, x, y);
00177 
00178         if((layers & HEXLAYER_SNOW) || (layers & HEXLAYER_DEEP_SNOW)) {
00179                 data = MAX(0, data - depth);
00180                 steamLength = abs(data - GetHexLayerData(map, x, y));
00181 
00182                 if(data == 0)
00183                         layers &= ~(HEXLAYER_SNOW | HEXLAYER_DEEP_SNOW);
00184                 else if(data <= 1000) {
00185                         layers |= HEXLAYER_SNOW;
00186                         layers &= ~HEXLAYER_DEEP_SNOW;
00187                 } else {
00188                         layers |= HEXLAYER_DEEP_SNOW;
00189                         layers &= ~HEXLAYER_SNOW;
00190                 }
00191 
00192                 SetHexLayers(map, x, y, layers);
00193                 SetHexLayerData(map, x, y, data);
00194 
00195                 if(emit) {
00196                         if(layers & HEXLAYER_DEEP_SNOW)
00197                                 snowDone = 1;
00198 
00199                         if(!snowDone && !((layers & HEXLAYER_SNOW) ||
00200                                                           (layers & HEXLAYER_DEEP_SNOW))) {
00201                                 HexLOSBroadcast(map, x, y,
00202                                                                 "%ch%cgThe snow in $h melts to nothingness!%cn");
00203                                 snowDone = 1;
00204                         }
00205 
00206                         if(!snowDone && ((oldLayers & HEXLAYER_DEEP_SNOW) &&
00207                                                          (!(layers & HEXLAYER_DEEP_SNOW)))) {
00208                                 HexLOSBroadcast(map, x, y,
00209                                                                 "%ch%cgThe snow in $h visibly melts!%cn");
00210                                 snowDone = 1;
00211                         }
00212                 }
00213         }
00214 
00215         if(IsIceHex(map, x, y)) {
00216                 if(depth >= (Elevation(map, x, y) * 200)) {
00217                         if(emit)
00218                                 HexLOSBroadcast(map, x, y, "The ice at $h breaks apart!");
00219 
00220                         breakIceAndSplashUnits(map, NULL, x, y,
00221                                                                    "goes swimming as ice breaks!");
00222                         steamLength = (Elevation(map, x, y) * 200);
00223                 }
00224         }
00225 
00226         if((steamLength > 0) && makeSteam) {
00227                 if(steamLength > 90)
00228                         steamLength = 90 + Number(0, steamLength / 20);
00229 
00230                 add_decoration(map, x, y, TYPE_SMOKE, SMOKE, steamLength);
00231         }
00232 }

void setWeatherHeatEffects ( MAP map,
MECH mech 
)

Definition at line 135 of file map.weather.c.

References FindLegHeatSinks(), MapTemperature, MechMinusHeat, MechX, and MechY.

00136 {
00137         if(MapEffectHvyRain(map))
00138                 MechMinusHeat(mech) -= 2.;
00139         else if(MapEffectRain(map))
00140                 MechMinusHeat(mech) -= 1.;
00141 
00142         if(MapEffectBlizzard(map))
00143                 MechMinusHeat(mech) -= 2.;
00144         else if(MapEffectHvySnow(map))
00145                 MechMinusHeat(mech) -= 1.;
00146 
00147         if(MapTemperature(map) < -30 || MapTemperature(map) > 50) {
00148                 if(MapTemperature(map) < -30)
00149                         MechMinusHeat(mech) += (-30 - MapTemperature(map) + 9) / 10;
00150                 else
00151                         MechMinusHeat(mech) -= (MapTemperature(map) - 50 + 9) / 10;
00152         }
00153 
00154         if(HexHasDeepSnow(map, MechX(mech), MechY(mech))) {
00155                 if(FindLegHeatSinks(mech) > 0)
00156                         MechMinusHeat(mech) -= 1.;
00157         }
00158 }

int validateWeatherConditions ( int  curConditions  ) 

Definition at line 16 of file map.weather.c.

00017 {
00018         int conditions = curConditions;
00019 
00020         if(conditions & WEATHER_PRECIP) {
00021                 if(conditions & WEATHER_HEAVY_PRECIP)
00022                         conditions &= ~WEATHER_PRECIP;
00023         }
00024 
00025         return conditions;
00026 }


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