///:://///////////////////////////////////////////// //:: Global Weather System v3.00 //:: weather_inc //:: Copyright (c) 2001 Bioware Corp. //::////////////////////////////////////////////// /* The purpose of this system is to create a global weather system that incorporates the four seasons of the year into your module. This is an include file, so if you make changes to this script you must recompile the scripts which use it. */ //::////////////////////////////////////////////// //:: Created By: MJ stone45@alltel.net //:: Created On: 12/13/04 //::////////////////////////////////////////////// #include "util_inc" // CLIMATE SYSTEM DETERMINATION TYPE // (Default: TRUE) // TRUE = System uses zone tags to determine the climate of the area. // FALSE = System uses zone variables to determine the climate of the area. // Note: Both are set in the toolset under Advanced options of the area // properties menu. const int WEATHER_TAGS = TRUE; // Toggles - Turn features on/off. // (default: TRUE). Toggling these on and off will make certain parts of // the weather system non-functional. None are interdependant so, any of // them can be on or off at any given time. // TRUE = On // FALSE = Off // WEATHER_SYSTEM = Toggle the entire system on/off. // WEATHER_FOG = Toggle fog effects on/off. // WEATHER_SKYBOX = Toggle skybox effects on/off. // WEATHER_DAMAGE = Toggle Heat/Cold damage on/off. // WIND_EFFECTS = Toggle Wind system on/off. // LIGHTNING_EFFECTS = Toggle Lightning visual effects on/off. // BLIZZARD_EFFECTS = Toggle Blizard visual effects on/off. // SANDSTORM_EFFECTS = Toggle Sandstorm visual effects on/off. // STORM_THUNDER = Toggle Thunderstorm system on/off. // STORM_BLIZZARD = Toggle Blizzard system on/off. // STORM_SAND = Toggle Sandstorm system on/off. // NEWBIE_FRIENDLY = Toggle system Newbie Friendly. const int WEATHER_SYSTEM = TRUE; const int WEATHER_FOG = FALSE; const int WEATHER_SKYBOX = FALSE; const int WEATHER_DAMAGE = FALSE; const int WIND_EFFECTS = FALSE; const int LIGHTNING_EFFECTS = FALSE; const int BLIZZARD_EFFECTS = FALSE; const int SANDSTORM_EFFECTS = FALSE; const int STORM_THUNDER = FALSE; const int STORM_BLIZZARD = FALSE; const int STORM_SAND = FALSE; const int NEWBIE_FRIENDLY = FALSE; // The minimum and maximum time between weather system checks. // Duration times in minutes(real time). const int nMin = 2; const int nMax = 10; // The maximum time between Lightning/Blizzard/Sand etc strikes. // Duration in seconds. const int nStrikeTime = 15; // The maximum time between wind gusts. The Wind system uses a random number // between 1 and the number you choose here. The higher the number the greater // the chance of delay. Default: 60 // Duration in seconds. const int nWindDelay = 60; // The maximum level at which a player will experiece the most adverse // effects of the environment. The higher the number, the longer the player // can be out in the elements without experiencing the most advesere // conditions. const int nWEMax = 15; // This is the maximum level that players will be protected from the // elements. Meaning that any player below level will NOT have any // damage applied to them from the elements (Cold/Heat, etc). Lightning, // blizards and other such things can still cause damage though. // This is put in for newbie friendly modules. Will only work if the // above NEWBIE_FRIENDLY constant is set to true. Default lvl: 3 const int NEWB_LVL = 3; // The time, in seconds, that a campfire will last before going out. // Assumes that the default of 2 Real Life minutes = 1 game hour. // 1 hour = 120.0 // 2 hours = 240.0 // 3 hours = 360.0 // etc. const float CAMPFIRE_HOURS = 360.0; // Storm System Damage Constants // The maximum damage caused by a lightning strike, blizzard, sandstorm, etc. const int nLightningDam = 5; const int nSandDam = 5; const int nBlizzardDam = 5; // Fog System Constants. // These are base numbers, and will be added to or subtracted from by the // script below. // FOG_DAWN = Amount of fog that will show up during the dawn hours. // FOG_DUSK = Amount of fog that will show up during the evening hours. // FOG_NIGHT = Amount of fog that will show up during the night. // FOG_RAIN = Amount of fog during rainy weather. // FOG_PERCENT = Percent chance that fog will occur as a result of the time // of day. The higher the number, the greater the chance that // fog will take place during the morning, evening, or night time. const int FOG_DAWN = 35; const int FOG_DUSK = 25; const int FOG_NIGHT = 20; const int FOG_RAIN = 50; const int FOG_PERCENT = 15; // The DC that determines the heat/chill factor save. The lower, the easier it is // for the PC to succeed. const int nDC = 15; // Storm System Constants // nBaseTStorm = (Default: 15) The percent chance of a thunderstorm occuring if it's raining. // nBaseBlizzard = (Default: 15) The percent chance of a blizzard occuring if it's snowing. // nBaseSStorm = (Default: 15) The percent chance of a sandstorm occuring if climate is desert. const int nBaseTStorm = 30; const int nBaseBlizzard = 25; const int nBaseSStorm = 20; // Do not edit any of the the below constants. They are used by the script // as place holders. const int SEASON_WINTER = 1; const int SEASON_SPRING = 2; const int SEASON_SUMMER = 3; const int SEASON_FALL = 4; // Variable Constants. // VAR_STORM = 0) No Storm // 1) ThunderStorm // 2) Blizard // 3) Sandstorm const string VAR_SEASON_STORE = "SEASON"; const string CLIMATE_DESIGNATOR_TAG = "climate_designator"; const string VAR_STORM = "STORM_STORE"; const string WEATHER_FACTOR = "Weather_Factor"; const string PC_OUTDOORS = "PC_Outdoors"; /*-----------------------------*/ /* Script Functions Start Here */ // Area's that should be excluded from the system. void WeatherExceptions() { // this is where you add specific areas in that you want to keep // the same weather in at all times, for example deserts should // be clear and mountains could have snow, etc, etc // the GetObjectByTag() function should have the area tag in it // you can get this from the properties window of the area // examples: //SetWeather(GetObjectByTag("AreaDesert"), WEATHER_CLEAR); //SetWeather(GetObjectByTag("AreaBeach"), WEATHER_RAIN); //SetWeather(GetObjectByTag("AreaMountain"), WEATHER_SNOW); } // Set the season for the module. void SetGlobalSeason() { int nMonth = GetCalendarMonth(); int nSeason; object oMod = GetModule(); // Winter (Months 1-2, & 12) if (nMonth < 3 || nMonth == 12) { nSeason = SEASON_WINTER; } // Spring (Months 3 - 5) else if (nMonth >= 3 && nMonth < 6) { nSeason = SEASON_SPRING; } // Summer (Months 6 - 8) else if (nMonth >= 6 && nMonth < 9) { nSeason = SEASON_SUMMER; } // Fall (Months 9 - 11) else if (nMonth >= 9 && nMonth <= 11) { nSeason = SEASON_FALL; } SetLocalInt(oMod, VAR_SEASON_STORE, nSeason); } // Heat/Cold Damage System // // Function that applies damage to a PC due to climate or weather void ApplyWeatherDamage() { int nDuration = nMin + Random(nMax - nMin); object oPC = GetFirstPC(); object oMod = GetModule(); object oArea, oCampfire; int nSave; effect eSlow, eDmg, eBonus, eBonus2; string sMsg, sMsg2, sClimateValue; int nWeatherFactor, nElementFactor, iClimateValue, nClimateZone; int nSlowFactor, nDmgFactor, nPCCondition; int nWEMinor, nWESevere, nWEMajor; if (WEATHER_DAMAGE == TRUE) { // Cycle through PCs while (oPC != OBJECT_INVALID) { // Reset variables. nElementFactor = 0; nSave = 0; oArea = GetArea(oPC); nSlowFactor = 0; nDmgFactor = 0; // Determine weather factor for PC // Area is outdoors if (GetIsAreaInterior(GetArea(oPC)) != TRUE) { // Deteremine any prior effects nWeatherFactor = GetLocalInt(oPC, WEATHER_FACTOR); // Determine if PC is close to a campfire to stay warm. oCampfire = GetNearestObjectByTag("MJ_CampFireP", oPC); if (oCampfire != OBJECT_INVALID) { if (GetDistanceBetween(oCampfire, oPC) < 10.0) { // Determine if it is summer of desert region if (WEATHER_TAGS == TRUE) { sClimateValue = GetSubString(GetTag(oArea), 2, 3); iClimateValue = StringToInt(sClimateValue); if (iClimateValue == 103) { nWeatherFactor += 1; //SendMessageToPC(oPC, "Desert Climate!"); } } else if (WEATHER_TAGS == FALSE) { nClimateZone = GetLocalInt(oArea, "CLIMATEZONE"); nWeatherFactor += 1; //SendMessageToPC(oPC, "Desert Climate!"); } // Summer Climate if (GetLocalInt(oMod, VAR_SEASON_STORE) == SEASON_SUMMER) { nWeatherFactor += 1; //SendMessageToPC(oPC, "Summer!"); } else if (GetLocalInt(oMod, VAR_SEASON_STORE) != SEASON_SUMMER) { // It is not Summer and not a Desert climate so decrease factor for warmth in the cold if (nWeatherFactor == 0) nWeatherFactor = 0; else nWeatherFactor -= 1; //SendMessageToPC(oPC, "Campfire close!!!"); } } } else // No campfire around { // Increase variable by one nWeatherFactor += 1; // SendMessageToPC(oPC, "No Campfire."); } // Set new value if (nWeatherFactor > nWEMax) nWeatherFactor = nWEMax; SetLocalInt(oPC, WEATHER_FACTOR, nWeatherFactor); // SendMessageToPC(oPC, "OUTDOORS: Weather Factor: " + IntToString(nWeatherFactor)); // Set PC as being effect by the weather SetLocalInt(oPC, PC_OUTDOORS, 1); } // Area is indoors else if (GetIsAreaInterior(GetArea(oPC)) == TRUE) { // Deteremine any prior effects nWeatherFactor = GetLocalInt(oPC, WEATHER_FACTOR); nPCCondition = GetLocalInt(oPC, PC_OUTDOORS); // if factor is 0 & the PC was outdoors remove adverse effects if (nWeatherFactor == 0 && nPCCondition == 1) { effect eLoop=GetFirstEffect(oPC); while (GetIsEffectValid(eLoop)) { if (GetEffectType(eLoop)==EFFECT_TYPE_BLINDNESS) RemoveEffect(oPC, eLoop); if (GetEffectType(eLoop)==EFFECT_TYPE_CONFUSED) RemoveEffect(oPC, eLoop); if (GetEffectType(eLoop)==EFFECT_TYPE_ABILITY_DECREASE) RemoveEffect(oPC, eLoop); eLoop=GetNextEffect(oPC); } SetLocalInt(oPC, PC_OUTDOORS, 0); SendMessageToPC(oPC, "You have fully recovered from the adverse weather conditions."); } // Decrease variable by one if (nWeatherFactor == 0) nWeatherFactor = 0; else nWeatherFactor -= 1; // Set new value SetLocalInt(oPC, WEATHER_FACTOR, nWeatherFactor); // SendMessageToPC(oPC, "INDOORS: Weather Factor: " + IntToString(nWeatherFactor)); return; } // Determine Seasonal Factor switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_WINTER: if (GetIsNight() == TRUE) nElementFactor += 5; // Cooler during the night else nElementFactor += 3; // Warmer during the day break; case SEASON_SUMMER: if (GetIsNight() == TRUE) nElementFactor += 3; // Cooler during the night else nElementFactor += 5; // Warmer during the day break; case SEASON_FALL: case SEASON_SPRING: break; } // Determine Weather Factor switch (GetWeather(oArea)) { case WEATHER_CLEAR: break; case WEATHER_RAIN: nElementFactor += 3; break; case WEATHER_SNOW: nElementFactor += 5; break; } // Determine Seasonal Bonus/Penalty for wearing armor. // Any armor/clothing weighing more then 25lbs is a help/hinderance. object oArmor = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC); switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_SUMMER: case SEASON_FALL: if (oArmor != OBJECT_INVALID && GetWeight(oArmor) > 25) nElementFactor += 4; else nElementFactor -= 4; break; case SEASON_WINTER: if (oArmor != OBJECT_INVALID && GetWeight(oArmor) > 25) nElementFactor -= 4; else nElementFactor += 4; break; case SEASON_SPRING: break; } // Determine Seasonal Bonus/Penalty for wearing a cloak. // Wearing a cloak is a help/hinderance. object oCloak = GetItemInSlot(INVENTORY_SLOT_CLOAK, oPC); switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_SUMMER: case SEASON_FALL: if (oCloak != OBJECT_INVALID) nElementFactor += 4; else nElementFactor -= 4; break; case SEASON_WINTER: if (oCloak != OBJECT_INVALID) nElementFactor -= 4; else nElementFactor += 4; break; case SEASON_SPRING: break; } // Determine Storm Damage if (GetLocalInt(oArea, VAR_STORM) == 2) { // Blizzard nElementFactor += 10; } // Determine Climate Element Damage & Set up Climate Save // Set up Climate Save & Effects if (WEATHER_TAGS == TRUE) { sClimateValue = GetSubString(GetTag(oArea), 2, 3); iClimateValue = StringToInt(sClimateValue); switch (iClimateValue) { case 100: // Moderate Climate - Depends on Season switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_SUMMER: nElementFactor += 5; nSave = SAVING_THROW_TYPE_FIRE; nDmgFactor = DAMAGE_TYPE_FIRE; nSlowFactor = 0; sMsg = "You start to sweat in the intense heat."; break; case SEASON_FALL: case SEASON_SPRING: break; case SEASON_WINTER: nElementFactor += 5; nSave = SAVING_THROW_TYPE_COLD; nSlowFactor = 25; nDmgFactor = DAMAGE_TYPE_COLD; sMsg = "You shiver as your bones start to chill."; break; } break; case 101: // Jungle Climate - Always hot/humid nElementFactor += 5; nSave = SAVING_THROW_TYPE_FIRE; nDmgFactor = DAMAGE_TYPE_FIRE; nSlowFactor = 0; sMsg = "You start to sweat in the intense heat."; break; case 102: // Polar Climate - Always cold nElementFactor += 10; nSave = SAVING_THROW_TYPE_COLD; nSlowFactor = 25; nDmgFactor = DAMAGE_TYPE_COLD; sMsg = "You shiver as your bones start to chill."; break; case 103: // Desert Climate - Always hot nElementFactor += 10; nSave = SAVING_THROW_TYPE_FIRE; nDmgFactor = DAMAGE_TYPE_FIRE; nSlowFactor = 0; sMsg = "You start to sweat in the intense heat."; break; case 104: // Highland Climate - always cool/wet nElementFactor += 3; nSave = SAVING_THROW_TYPE_COLD; nSlowFactor = 25; nDmgFactor = DAMAGE_TYPE_COLD; sMsg = "You shiver as your bones start to chill."; break; } } else if (WEATHER_TAGS == FALSE) { nClimateZone = GetLocalInt(oArea, "CLIMATEZONE"); switch (nClimateZone) { case 100: // Moderate Climate - Depends on Season switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_SUMMER: nElementFactor += 5; nSave = SAVING_THROW_TYPE_FIRE; nDmgFactor = DAMAGE_TYPE_FIRE; nSlowFactor = 0; sMsg = "You start to sweat in the intense heat."; break; case SEASON_FALL: case SEASON_SPRING: break; case SEASON_WINTER: nElementFactor += 5; nSave = SAVING_THROW_TYPE_COLD; nSlowFactor = 25; nDmgFactor = DAMAGE_TYPE_COLD; sMsg = "You shiver as your bones start to chill."; break; } break; case 101: // Jungle Climate - Always hot/humid nElementFactor += 5; nSave = SAVING_THROW_TYPE_FIRE; nDmgFactor = DAMAGE_TYPE_FIRE; nSlowFactor = 0; sMsg = "You start to sweat in the intense heat."; break; case 102: // Polar Climate - Always cold nElementFactor += 10; nSave = SAVING_THROW_TYPE_COLD; nSlowFactor = 25; nDmgFactor = DAMAGE_TYPE_COLD; sMsg = "You shiver as your bones start to chill."; break; case 103: // Desert Climate - Always hot nElementFactor += 10; nSave = SAVING_THROW_TYPE_FIRE; nDmgFactor = DAMAGE_TYPE_FIRE; nSlowFactor = 0; sMsg = "You start to sweat in the intense heat."; break; case 104: // Highland Climate - always cool/wet nElementFactor += 3; nSave = SAVING_THROW_TYPE_COLD; nSlowFactor = 25; nDmgFactor = DAMAGE_TYPE_COLD; sMsg = "You shiver as your bones start to chill."; break; } } // Apply effects according to weather factor nWEMinor = (nWEMax * 25)/100; nWESevere = (nWEMax * 50)/100; nWEMajor = (nWEMax *75)/100; // Minor Effects if (GetLocalInt(oPC, WEATHER_FACTOR) < nWEMinor) { eSlow = EffectMovementSpeedDecrease(nSlowFactor); } // Severe Effects else if (GetLocalInt(oPC, WEATHER_FACTOR) < nWESevere) { nSlowFactor += 15; eSlow = EffectMovementSpeedDecrease(nSlowFactor); if (nDmgFactor == DAMAGE_TYPE_COLD) { if (GetAbilityScore(oPC, ABILITY_CONSTITUTION) > 2) eBonus = EffectLinkEffects(EffectAbilityDecrease(ABILITY_DEXTERITY, 1),EffectAbilityDecrease(ABILITY_CONSTITUTION, 1)); else eBonus = EffectAbilityDecrease(ABILITY_DEXTERITY, 1); } else if (nDmgFactor == DAMAGE_TYPE_FIRE) { if (GetAbilityScore(oPC, ABILITY_CONSTITUTION) > 2) eBonus = EffectLinkEffects(EffectAbilityDecrease(ABILITY_STRENGTH, 1),EffectAbilityDecrease(ABILITY_CONSTITUTION, 1)); else eBonus = EffectAbilityDecrease(ABILITY_STRENGTH, 1); } } // Major Effects else if (GetLocalInt(oPC, WEATHER_FACTOR) < nWEMajor) { nSlowFactor += 30; eSlow = EffectMovementSpeedDecrease(nSlowFactor); eDmg = EffectDamage(3, nDmgFactor); sMsg2 = "The elements will take control of your body and mind soon."; if (nDmgFactor == DAMAGE_TYPE_COLD) { if (GetAbilityScore(oPC, ABILITY_CONSTITUTION) > 2) eBonus = EffectLinkEffects(EffectAbilityDecrease(ABILITY_DEXTERITY, 2),EffectAbilityDecrease(ABILITY_CONSTITUTION, 2)); else eBonus = EffectAbilityDecrease(ABILITY_DEXTERITY, 2); } else if (nDmgFactor == DAMAGE_TYPE_FIRE) { if (GetAbilityScore(oPC, ABILITY_CONSTITUTION) > 2) eBonus = EffectLinkEffects(EffectAbilityDecrease(ABILITY_STRENGTH, 2),EffectAbilityDecrease(ABILITY_CONSTITUTION, 2)); else eBonus = EffectAbilityDecrease(ABILITY_STRENGTH, 2); } } // Max Effects else if (GetLocalInt(oPC, WEATHER_FACTOR) == nWEMax) { nSlowFactor += 60; eSlow = EffectMovementSpeedDecrease(nSlowFactor); eDmg = EffectDamage(5, nDmgFactor); sMsg2 = "The elements are taking their toll on your body and mind."; if (nDmgFactor == DAMAGE_TYPE_COLD) { if (GetAbilityScore(oPC, ABILITY_CONSTITUTION) > 2) eBonus = EffectLinkEffects(EffectAbilityDecrease(ABILITY_DEXTERITY, 2),EffectAbilityDecrease(ABILITY_CONSTITUTION, 2)); else eBonus = EffectAbilityDecrease(ABILITY_DEXTERITY, 2); } else if (nDmgFactor == DAMAGE_TYPE_FIRE) { if (GetAbilityScore(oPC, ABILITY_CONSTITUTION) > 2) eBonus = EffectLinkEffects(EffectAbilityDecrease(ABILITY_STRENGTH, 2),EffectAbilityDecrease(ABILITY_CONSTITUTION, 2)); else eBonus = EffectAbilityDecrease(ABILITY_STRENGTH, 2); } } // Make Save if necessary & apply damage if (nSave != 0 && nElementFactor > 0) { nElementFactor += nDC; if (FortitudeSave(oPC, nElementFactor, nSave) == 0) { // Failure ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eSlow,oPC,30.0); ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBonus,oPC,120.0); if ( (NEWBIE_FRIENDLY == FALSE) || (NEWBIE_FRIENDLY == TRUE && GetHitDice(oPC) > NEWB_LVL) ) ApplyEffectToObject(DURATION_TYPE_INSTANT,eDmg,oPC,1.0); SendMessageToPC(oPC,sMsg); SendMessageToPC(oPC,sMsg2); // SendMessageToPC(oPC, "Effect Level: " + IntToString(nWeatherFactor)); } } oPC= GetNextPC(); // SendMessageToAllDMs("Weather Damage("+IntToString(nElementDmg)+") Effects Applied to: " + GetName(oPC)); } // Change the number below to alter the delay. Higher # = longer delay. DelayCommand(60.0 * IntToFloat(nDuration), ApplyWeatherDamage()); } } // Sandstorm Effect System void ApplySandStormEffects() { object oSandTgt; object oArea; if (SANDSTORM_EFFECTS == TRUE) { // Cycle through areas to determine if sandstorm visuals should be applied oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { if (GetLocalInt(oArea, VAR_STORM) == 3) { effect eVFX = EffectVisualEffect(VFX_IMP_DUST_EXPLOSION); location lLoc = util_GetRandomLocation(oArea); ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLoc, 3.0); oSandTgt = GetNearestObjectToLocation(OBJECT_TYPE_CREATURE, lLoc, 1); if (oSandTgt != OBJECT_INVALID) { if (GetDistanceBetweenLocations(lLoc, GetLocation(oSandTgt)) < 5.0 ) { if (GetIsPC(oSandTgt) || GetMaster(oSandTgt) != OBJECT_INVALID) { eVFX = EffectDamage(Random(nSandDam), DAMAGE_TYPE_PIERCING); ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSandTgt, 1.0); } } } // SendMessageToAllDMs("Sandstorm System Fired in: " + GetName(oArea)); } oArea = GetNextArea(); } } DelayCommand(IntToFloat(Random(nStrikeTime)), ApplySandStormEffects()); } // Wind Effect System void ApplyWindEffects() { object oArea, oWind; effect eWind = EffectKnockdown(); if (WIND_EFFECTS == TRUE) { if (GetLocalInt(oArea, VAR_STORM) == 0) { // Cycle through areas to determine if wind should be applied oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { location lLoc = util_GetRandomLocation(oArea); oWind = GetNearestObjectToLocation(OBJECT_TYPE_CREATURE, lLoc, 1); int nRanWind = Random(3); if (nRanWind == 1) AssignCommand(oWind, PlaySound("as_wt_gustsoft1")); else if (nRanWind == 2) AssignCommand(oWind, PlaySound("as_wt_gustgrass1")); else if (nRanWind == 3) AssignCommand(oWind, PlaySound("as_wt_guststrng1")); if (oWind != OBJECT_INVALID) { if (GetDistanceBetweenLocations(lLoc, GetLocation(oWind)) < 7.0 ) { if (GetIsPC(oWind) || GetMaster(oWind) != OBJECT_INVALID) { if (GetIsResting(oWind) != TRUE) { if (ReflexSave(oWind, nDC) == 0) { ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eWind, oWind, 3.0); SendMessageToPC(oWind, "The wind has knocked you off balance."); } } } } // SendMessageToAllDMs("Wind System Fired in: " + GetName(oArea)); } oArea = GetNextArea(); } } } DelayCommand(IntToFloat(Random(nWindDelay)), ApplyWindEffects()); } // Lightning Effect System void ApplyLightningEffects() { object oStrike; object oArea; if (LIGHTNING_EFFECTS == TRUE) { // Cycle through areas to determine if lightning should be applied oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { if (GetLocalInt(oArea, VAR_STORM) == 1) { effect eVFX = EffectVisualEffect(VFX_IMP_LIGHTNING_M); location lLoc = util_GetRandomLocation(oArea); ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLoc, 3.0); oStrike = GetNearestObjectToLocation(OBJECT_TYPE_CREATURE, lLoc, 1); if (oStrike != OBJECT_INVALID) { if (GetDistanceBetweenLocations(lLoc, GetLocation(oStrike)) < 5.0 ) { if (GetIsPC(oStrike) || GetMaster(oStrike) != OBJECT_INVALID) { eVFX = EffectDamage(Random(nLightningDam), DAMAGE_TYPE_ELECTRICAL); ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oStrike, 1.0); } } } // SendMessageToAllDMs("Lightning System Fired in: " + GetName(oArea)); } oArea = GetNextArea(); } } DelayCommand(IntToFloat(Random(nStrikeTime)), ApplyLightningEffects()); } // Blizzard Effect System void ApplyBlizzardEffects() { object oIceTgt; object oArea; if (BLIZZARD_EFFECTS == TRUE) { // Cycle through areas to determine if blizzard visuals should be applied oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { if (GetLocalInt(oArea, VAR_STORM) == 2) { effect eVFX = EffectVisualEffect(VFX_FNF_ICESTORM); location lLoc = util_GetRandomLocation(oArea); ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVFX, lLoc, 3.0); oIceTgt = GetNearestObjectToLocation(OBJECT_TYPE_CREATURE, lLoc, 1); if (oIceTgt != OBJECT_INVALID) { if (GetDistanceBetweenLocations(lLoc, GetLocation(oIceTgt)) < 10.0 ) { if (GetIsPC(oIceTgt) || GetMaster(oIceTgt) != OBJECT_INVALID) { eVFX = EffectDamage(Random(nBlizzardDam), DAMAGE_TYPE_PIERCING); ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oIceTgt, 1.0); } } } // SendMessageToAllDMs("Blizzard System Fired in: " + GetName(oArea)); } oArea = GetNextArea(); } } DelayCommand(IntToFloat(Random(nStrikeTime)), ApplyBlizzardEffects()); } // Thunderstorm System void WeatherThunderStorm() { int nStormChance; int nTStormChance = 0; object oArea; object oMod = GetModule(); switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_WINTER: nTStormChance = 1; break; case SEASON_SUMMER: nTStormChance = 5; break; case SEASON_FALL: case SEASON_SPRING: nTStormChance = 10; break; } if (STORM_THUNDER == TRUE) { oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { if (GetWeather(oArea) == WEATHER_RAIN) { if (WEATHER_TAGS == TRUE) { string sStringValue1 = GetStringLeft(GetTag(oArea), 2); string sStringValue2 = GetSubString(GetTag(oArea), 2, 3); if (sStringValue1 == "ZN") { // Area has a climate int iStringValue = StringToInt(sStringValue2); switch (iStringValue) { case 100: // Moderate Climate nTStormChance += 5; break; case 101: // Jungle Climate nTStormChance += 10; break; case 102: // Polar Climate nTStormChance += 1; break; case 103: // Desert Climate nTStormChance = 0; break; case 104: // Highland Climate nTStormChance += 5; break; } } } else if (WEATHER_TAGS == FALSE) { int nClimateZone = GetLocalInt(oArea, "CLIMATEZONE"); if (nClimateZone != 0) { // Area has a climate switch (nClimateZone) { case 100: // Moderate Climate nTStormChance += 5; break; case 101: // Jungle Climate nTStormChance += 10; break; case 102: // Polar Climate nTStormChance += 1; break; case 103: // Desert Climate nTStormChance = 0; break; case 104: // Highland Climate nTStormChance += 5; break; } } } nStormChance = d100(); nTStormChance += nBaseTStorm; if (nStormChance < nTStormChance) { // Set Local Variable for area. SetLocalInt(oArea, VAR_STORM, 1); // Add in Lightning Effects ApplyLightningEffects(); // Add in Wind Effects ApplyWindEffects(); // Send Message to DMs // SendMessageToAllDMs("Thunderstorm in: " + GetName(oArea)); } } oArea = GetNextArea(); } } } // Blizzard System void WeatherBlizzard() { int nStormChance; int nBlizzardChance = 0; object oArea; object oMod = GetModule(); switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_WINTER: nBlizzardChance = 10; break; case SEASON_SUMMER: nBlizzardChance = 0; break; case SEASON_FALL: case SEASON_SPRING: nBlizzardChance = 0; break; } if (STORM_BLIZZARD == TRUE) { oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { if (GetWeather(oArea) == WEATHER_SNOW) { if (WEATHER_TAGS == TRUE) { string sStringValue1 = GetStringLeft(GetTag(oArea), 2); string sStringValue2 = GetSubString(GetTag(oArea), 2, 3); if (sStringValue1 == "ZN") { // Area has a climate int iStringValue = StringToInt(sStringValue2); switch (iStringValue) { case 100: // Moderate Climate nBlizzardChance += 5; break; case 101: // Jungle Climate nBlizzardChance = 0; break; case 102: // Polar Climate nBlizzardChance += 10; break; case 103: // Desert Climate nBlizzardChance = 0; break; case 104: // Highland Climate nBlizzardChance += 5; break; } } } else if (WEATHER_TAGS == FALSE) { int nClimateZone = GetLocalInt(oArea, "CLIMATEZONE"); if (nClimateZone != 0) { // Area has a climate switch (nClimateZone) { case 100: // Moderate Climate nBlizzardChance += 5; break; case 101: // Jungle Climate nBlizzardChance = 0; break; case 102: // Polar Climate nBlizzardChance += 10; break; case 103: // Desert Climate nBlizzardChance = 0; break; case 104: // Highland Climate nBlizzardChance += 5; break; } } } nStormChance = d100(); nBlizzardChance += nBaseBlizzard; if (nStormChance < nBlizzardChance) { // Set Local Variable for area. SetLocalInt(oArea, VAR_STORM, 2); // Add in Blizzard Effects ApplyBlizzardEffects(); // Add in Wind Effects ApplyWindEffects(); // Send Message to DMs // SendMessageToAllDMs("Blizzard in: " + GetName(oArea)); } } oArea = GetNextArea(); } } } // Sandstorm System void WeatherSandStorm() { int nStormChance; int nSStormChance = 0; object oArea; object oMod = GetModule(); switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_WINTER: nSStormChance = 0; break; case SEASON_SUMMER: nSStormChance = 10; break; case SEASON_FALL: case SEASON_SPRING: nSStormChance = 5; break; } if (STORM_SAND == TRUE) { oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { if (WEATHER_TAGS == TRUE) { string sZoneTag = GetStringLeft(GetTag(oArea), 5); if (sZoneTag == "ZN103") { nStormChance = d100(); nSStormChance += 10; nSStormChance += nBaseSStorm; if (nStormChance < nSStormChance) { // Set Local Variable for area. SetLocalInt(oArea, VAR_STORM, 3); // Add in Sandstorm Effects ApplySandStormEffects(); // Add in Wind Effects ApplyWindEffects(); // Send Message to DMs // SendMessageToAllDMs("Sandstorm in: " + GetName(oArea)); } } } else if (WEATHER_TAGS == FALSE) { int nClimateZone = GetLocalInt(oArea, "CLIMATEZONE"); if (nClimateZone == 103) { nStormChance = d100(); nSStormChance += 10; nSStormChance += nBaseSStorm; if (nStormChance < nSStormChance) { // Set Local Variable for area. SetLocalInt(oArea, VAR_STORM, 3); // Add in Sandstorm Effects ApplySandStormEffects(); // Add in Wind Effects ApplyWindEffects(); // Send Message to DMs // SendMessageToAllDMs("Sandstorm in: " + GetName(oArea)); } } } oArea = GetNextArea(); } } } // Set the global weather. void SetGlobalWeather() { int nDuration = nMin + Random(nMax - nMin); object oMod = GetModule(); // Global Weather Variables int nClearChance, nRainChance, nSnowChance, nWeather, nSky, nWind; // Climate Variables int nJungleClear, nJungleRain, nJungleSnow, nJungleSky; int nModerateClear, nModerateRain, nModerateSnow, nModerateSky; int nPolarClear, nPolarRain, nPolarSnow, nPolarSky; int nDesertClear, nDesertRain, nDesertSnow, nDesertSky; int nHighlandClear, nHighlandRain, nHighlandSnow, nHighlandSky; // Climate Weather Variables int nJungleWeather, nModerateWeather, nPolarWeather, nDesertWeather, nHighlandWeather; if (WEATHER_SYSTEM == TRUE) { // Determine Season for Module SetGlobalSeason(); // Determine Seasonal Base Modifier. This is the % chance of a given weather pattern. // nClearChance, nRainChance, nSnowChance: must add up to 60 switch (GetLocalInt(oMod, VAR_SEASON_STORE)) { case SEASON_WINTER: SendMessageToAllDMs("Season: Winter"); nClearChance = 5; nRainChance = 5; nSnowChance = 50; break; case SEASON_SPRING: SendMessageToAllDMs("Season: Spring"); nClearChance = 20; nRainChance = 35; nSnowChance = 5; break; case SEASON_SUMMER: SendMessageToAllDMs("Season: Summer"); nClearChance = 50; nRainChance = 10; nSnowChance = 0; break; case SEASON_FALL: SendMessageToAllDMs("Season: Fall"); nClearChance = 40; nRainChance = 10; nSnowChance = 10; break; } // Set up base % for climates // Must add up to 40 // Moderate - Summer Season if (GetLocalInt(oMod, VAR_SEASON_STORE) == SEASON_SUMMER) { nModerateClear = nClearChance + 20; nModerateRain = nRainChance + nSnowChance + 20; nModerateSnow = 0; } // Moderate - Winter/Fall/Spring Seasons else { nModerateClear = nClearChance + 18; nModerateRain = nRainChance + 17; nModerateSnow = nSnowChance + 5; } // Jungle nJungleClear = nClearChance + 10; nJungleRain = nRainChance + nSnowChance + 30; nJungleSnow = 0; // Polar nPolarClear = nClearChance + 5; nPolarRain = nRainChance + 5; nPolarSnow = nSnowChance + 30; // Desert - no base needed. Add in if rain/snow possible in desert. // Highland nHighlandClear = nClearChance + 5; nHighlandRain = nRainChance + 30; nHighlandSnow = nSnowChance + 5; // Calculate Climate Base percents // Moderate nModerateRain += nModerateClear; nModerateSnow += nModerateRain; // Jungle nJungleRain += nJungleClear; nJungleSnow += nJungleRain; // Polar nPolarRain += nPolarClear; nPolarSnow += nPolarRain; // Desert - no need to calculate. Add in if rain/snow possible in desert. nHighlandRain += nHighlandClear; nHighlandSnow += nHighlandRain; // Determine Random number for all weather paterns to use. int nRandom = d100(); // Determine Weather/Sky in each climate zone // Moderate if (nRandom < nModerateClear) { nModerateWeather = WEATHER_CLEAR; nModerateSky = SKYBOX_GRASS_CLEAR; } else if (nRandom < nModerateRain) { nModerateWeather = WEATHER_RAIN; nModerateSky = SKYBOX_GRASS_STORM; } else { nModerateWeather = WEATHER_SNOW; nModerateSky = SKYBOX_ICY; } // Jungle if (nRandom < nJungleClear) { nJungleWeather = WEATHER_CLEAR; nJungleSky = SKYBOX_GRASS_CLEAR; } else if (nRandom < nJungleRain) { nJungleWeather = WEATHER_RAIN; nJungleSky = SKYBOX_GRASS_STORM; } else { nJungleWeather = WEATHER_SNOW; nJungleSky = SKYBOX_ICY; } // Polar if (nRandom < nPolarClear) { nPolarWeather = WEATHER_CLEAR; nPolarSky = SKYBOX_WINTER_CLEAR; } else if (nRandom < nPolarRain) { nPolarWeather = WEATHER_RAIN; nPolarSky = SKYBOX_ICY; } else { nPolarWeather = WEATHER_SNOW; nPolarSky = SKYBOX_ICY; } // Desert - no rain/snow nDesertWeather = WEATHER_CLEAR; nDesertSky = SKYBOX_DESERT_CLEAR; // Highland if (nRandom < nHighlandClear) { nHighlandWeather = WEATHER_CLEAR; nHighlandSky = SKYBOX_GRASS_CLEAR; } else if (nRandom < nHighlandRain ) { nHighlandWeather = WEATHER_RAIN; nHighlandSky = SKYBOX_GRASS_STORM; } else { nHighlandWeather = WEATHER_SNOW; nHighlandSky = SKYBOX_ICY; } // Cycle through all areas setting weather by zone object oArea = GetFirstArea(); while (GetIsObjectValid(oArea)) { // System is using TAGS to determine climate if (WEATHER_TAGS == TRUE) { string sStringValue1 = GetStringLeft(GetTag(oArea), 2); string sStringValue2 = GetSubString(GetTag(oArea), 2, 3); if (sStringValue1 == "ZN") { // Area has a climate int iStringValue = StringToInt(sStringValue2); switch (iStringValue) { case 100: // Moderate Climate nWeather = nModerateWeather; nSky = nModerateSky; break; case 101: // Jungle Climate nWeather = nJungleWeather; nSky = nJungleSky; break; case 102: // Polar Climate nWeather = nPolarWeather; nSky = nPolarSky; break; case 103: // Desert Climate nWeather = nDesertWeather; nSky = nDesertSky; break; case 104: // Highland Climate nWeather = nHighlandWeather; nSky = nHighlandSky; break; } SetWeather(oArea, nWeather); if (WEATHER_SKYBOX == TRUE) SetSkyBox(nSky, oArea); // SendMessageToAllDMs("Setting Area: " + GetName(oArea) + " to climate: " +IntToString(nWeather)); } else { // Area uses default climate (Moderate) nWeather = nModerateWeather; nSky = nModerateSky; SetWeather(oArea, nWeather); if (WEATHER_SKYBOX == TRUE) SetSkyBox(nSky,oArea); // SendMessageToAllDMs("Area: " + GetName(oArea) + " is using default climate."); } // System is using area variables to determine climate } else if (WEATHER_TAGS == FALSE) { int nClimateZone = GetLocalInt(oArea, "CLIMATEZONE"); if (nClimateZone != 0) { // Area has a climate switch (nClimateZone) { case 100: // Moderate Climate nWeather = nModerateWeather; nSky = nModerateSky; break; case 101: // Jungle Climate nWeather = nJungleWeather; nSky = nJungleSky; break; case 102: // Polar Climate nWeather = nPolarWeather; nSky = nPolarSky; break; case 103: // Desert Climate nWeather = nDesertWeather; nSky = nDesertSky; break; case 104: // Highland Climate nWeather = nHighlandWeather; nSky = nHighlandSky; break; } SetWeather(oArea, nWeather); if (WEATHER_SKYBOX == TRUE) SetSkyBox(nSky, oArea); // SendMessageToAllDMs("Setting Area: " + GetName(oArea) + " to climate: " +IntToString(nWeather)); } else { // Area uses default climate (Moderate) nWeather = nModerateWeather; nSky = nModerateSky; SetWeather(oArea, nWeather); if (WEATHER_SKYBOX == TRUE) SetSkyBox(nSky,oArea); // SendMessageToAllDMs("Area: " + GetName(oArea) + " is using default climate."); } } // Fog Effects int nFogChance = d100(); int nFogRnd = d20(); // Random % to add to fog amount. int nFogType; int nFog; if (WEATHER_FOG == TRUE) { // For Weather if (GetWeather(oArea) == WEATHER_RAIN) { nFogType = FOG_TYPE_ALL; nFog += FOG_RAIN; } else if (GetWeather(oArea) == WEATHER_CLEAR) { nFogType = FOG_TYPE_ALL; nFog = 0; } // For time of day // This will not occur every time since the script is called at a random time. if (nFogChance < FOG_PERCENT) { if (GetIsDawn() == TRUE) { nFogType = FOG_TYPE_SUN; nFog += FOG_DAWN; } else if (GetIsDusk() == TRUE) { nFogType = FOG_TYPE_MOON; nFog += FOG_DUSK; } else if (GetIsNight() == TRUE) { nFogType = FOG_TYPE_MOON; nFog += FOG_NIGHT; } else { nFogType = FOG_TYPE_ALL; nFog = 0; } if (nFog > 0) { nFog += nFogRnd; SetFogAmount(nFogType, nFog, oArea); } } } // Storm System // Default area to no storm if resulting weather is clear. if (GetWeather(oArea) == WEATHER_CLEAR) SetLocalInt(oArea, VAR_STORM, 0); oArea = GetNextArea(); } // Storm System // Thunderstorm WeatherThunderStorm(); // Blizzard WeatherBlizzard(); // Sandstorm WeatherSandStorm(); // Process Weather Damage ApplyWeatherDamage(); // Process exceptions WeatherExceptions(); // run the weather function again after a certain amount of time DelayCommand(60.0 * IntToFloat(nDuration), SetGlobalWeather()); // SendMessageToAllDMs("The next check occurs in: " + IntToString(nDuration)); } } // Campfire procedure // Creates a campfire placeable at the location of the Player. void MakeCampFire(object oPC) { location lLoc = GetLocation(oPC); object oCampfire = CreateObject(OBJECT_TYPE_PLACEABLE, "mj_campfire", lLoc); // Destory the object after the time has elapsed. DestroyObject(oCampfire, CAMPFIRE_HOURS); }