uox3/source/cWeather.cpp
Xoduz 69a8c090cd 0.99.4x
Fixed an issue where the color of NPC corpse names would not always match up with the NPC's flag color
Fixed a bug where the baseRange and maxRange properties of ranged weapons would not get saved to world files. These values are now saved in the format of RANGE=baseRange,maxRange
Changed the way items are added to containers, to ensure that the order in which the items are displayed to the player always reflects the order in which they were added; now the most recent item added/moved in a container will always be rendered on top of older items.
Made adjustments to how items are randomly added to containers; should use more of a given container gump's available area now
Exposed Item property to JS engine, which contains serial of the creator of an item:
	.creator 	// contains serial of the creator of an item. If set, maker's marks will show up in the item's tooltip
Fixed an issue where JS engine would lose track of script context if one script used CreateDFNItem() or SpawnNPC() functions and the new objects had events that triggered upon creation. UOX3 now restores the original script context at the tail end of these functions.
Added new JS Event to allow inserting custom tooltip text for objects, which will be displayed in tooltips right after the object name. Any text returned from the event will be displayed, and the text can make use of the same HTML tags as gumps to make changes to color, font, etc.
	onTooltip( myObj ) 		// Triggers for objects right before the object's tooltip properties are sent to client
Updated 'tweak and 'set commands to refresh item being modified if movable state of item changes, so the change is reflected in nearby clients
Fixed an issue with NPC vendors and items bought from players not being properly removed from the vendor's "bought container" when players buy them again
Ported Item Identification skill from code to JS (js/skill/itemid.js) and removed hard-coded version
Implemented magic item generator in JS (js/item/magic_item.js). When this script is attached to an NPC, it has a chance to generate magic weapons, armors, wands/staffs and rings as loot on the NPC's corpse when slain. The chance of getting quality magical items increases with the fame level of the NPC in question. The types of magical items generated follows the pattern of such items as implemented in UO prior to the AoS expansion.
	Examples:
		exceedingly accurate war hammer of vanquishing
		substantial, accurate axe of power and Daemon's Breath
		silver long sword
		massive platemail arms of Protection
		metal shield of defense
		durable ringmail tunic of guarding
	All magic items have a chance to have spell effects attached (with rings/wands being guaranteed to have these), with a limited amount of charges available. For weapons, these effects activate on successful hits in combat, while for armors they activate on equip, and then periodically as long as the item is worn. Rings and wands/staffs have to be manually activated and targeted - with the exception of rings of invisibility, which activate the moment you equip them!
	Related scripts:
		js/item/magic_armor_equipeffects.js
		js/item/magic_weapon_accbonus.js
		js/item/magic_weapon_equip.js
		js/item/magic_weapon_spell_attack.js
	The magic item loot generation script has been attached to a number of different NPCs, all of which now have a chance to drop magic items as loot when defeated.
A bonus magical item - the glacial staff - has also been implemented (js/item/magic_glacial_staff.js), and has a chance to drop as loot from Giant Ice Serpents!
Fixed an issue with CustomTarget where the target message would not be displayed if the cursorType parameter was provided
Fixed bug with 'rename command, which referenced a non-existing variable that caused a script crash
Added additional object properties to 'get and 'set commands:
	.shouldSave 		// Determines if an item should be saved in worldfiles or not
	.baseRange 			// Determines the base range of a ranged weapon, less than which it becomes less effective
	.maxRange 			// Determines the max range of a ranged weapon, beyond which it cannot reach its target
The feature that allows stats like Strength, Dexterity and Intelligence to provide bonuses to skill checks has been turned into a UOX.INI setting, which is disabled by default. The bonuses have also been nerfed; they will no longer contribute more to the success of a skill check than the actual skill being checked!
	STATSAFFECTSKILLCHECKS=0/1 	// If enabled, stats can provide bonuses to skill checks based on the weighting for those stats as setup in dfndata/skills/skills.dfn
Updated damage tracking code to include the type of damage that was dealt (PHYSICAl vs HEAT vs COLD, etc)
Updated Character JS Method Damage() to include a new parameter that can specify the type of damage that was dealt to the character. The new parameter must always be included if other optional parameters are used. Note that updates might be required for scripts making use of this method.Updated syntax:
	.Damage( amount )
	.Damage( amount, damageType )
	.Damage( amount, damageType, attacker )
	.Damage( amount, damageType, attacker, doRepsys )
	Supported damageTypes:
		PHYSICAL 	= 1
		LIGHT 		= 2
		RAIN 		= 3
		COLD 		= 4
		HEAT 		= 5
		LIGHTNING 	= 6 // magic damage
		POISON 		= 7
		SNOW 		= 8
Updated JS Event OnDamage to include an additional parameter that describes the type of damage that was dealt. New syntax:
	onDamage( damaged, attacker, damageValue, damageType )
Updated JS Event OnSpellTarget to allow rejecting a spell being cast on a target by returning a value of 2 from the script
Split the character priv flag for magic reflection into a temporary one (one-time magic reflection spell) and a permanent one (innate permanent reflection ability). The temporary effect is put in place by Magic Reflection spell, and is removed after a successful spell reflect. The permanent one is an innate ability of a character and is not removed even after a spell is reflected.
Added new Character JS property to get/set state of a character's permanent magic reflect ability:
	.permanentMagicReflect 		// 0 = disable, 1 = enable
Added special abilities/effects for the following NPCs:
	Acid Elementals now have a chance to damage the melee weapons of their attackers
	Dull Copper Elementals now explode on death
	Shadow Iron Elemental is immune to targeted spell damage
	Copper Elementals have permanent magic reflect, and reflect some physical damage back at their attacker
	Bronze Elementals deal passive area damage to nearby players every 5 to 10 seconds
	Valorite Elementals have permanent magic reflect, reflect some physical damage back at their attacker
	Snow/Ice Elementals deal passive area damage to nearby players every 5 to 10 seconds
	Lava Serpents deal passive area damage to nearby players every 5 to 10 seconds
	Phoenixes deal passive area damage to nearby players every 5 to 10 seconds
	Pixies have a chance to cast a random spell upon receiving a death blow:
		Bless (target)
		Curse (target)
		Explosion (target)
		Greater Poison (target)
		Greater Heal (self, prevents death)
	Ethereal Warriors will now resurrect dead players with positive karma
	Ethereal Warriors now have a chance to drain target's health, stamina or mana on hit
	Fire Breath special ability added to the following NPCs, with the random ability damage scaling with the NPCs current health:
		Hell Cat, 5 to 8 dmg at max health
		Fire Steed, 6 to 9 dmg at max health
		Hell Hounds, 8 to 11 dmg at max health
		Lava Lizard, 8 to 11 dmg at max health
		Predator Hell Cat, 9 to 14 dmg at max health
		Sea Serpent, 11 to 17 dmg at max health
		Swamp Dragon, 15 to 22 dmg at max health
		Armored Swamp Dragon, 15 to 22 dmg at max health
		Fire Gargoyle, 20 to 30 dmg at max health
		Deep Sea Serpent, 21 to 32 dmg at max health
		Serpentine Dragon, 22 to 32 dmg at max health
		Drake (Gray), 22 to 32 dmg at max health
		Drake (Red), 22 to 32 dmg at max health
		Nightmare, 26 to 39 dmg at max health
		Dark Steed, 26 to 39 dmg at max health
		Silver Steed, 26 to 39 dmg at max health
		Kraken, 39 to 59 dmg at max health
		Dragon (Red), 41 to 62 dmg at max health
		Dragon (Gray), 41 to 62 dmg at max health
		Shadow Wyrm, 50 to 75 dmg at max health
		Reptalon, 51 to 77 dmg at max health
		Skeletal Dragon, 52 to 77 dmg at max health
		Ancient Wyrm, 60 to 90 dmg at max health
Update stats, skills and loot for all currently implemented NPCs
Removed an ancient piece of code that prevented corpses from being generated for various elementals and blade spirits on death. This was originally put in place because these creatures had no corpses, and would replace it with a backpack instead, but these creatures now all have corpses in all client versions supported by UOX3
Updated potions script (js/item/potion.js) with updated formula for amount of hitpoints healed by healing potions, and added restrictions for using them when at full health and/or if poisoned (Dragon Slayer)
Fixed a bug where creatures (and humans, if FORCENEWANIMATIONPACKET was disabled in uox.ini) would play animations with wrong frame count, causing the animations to either freeze for a few frames at the end, or get cut off a couple of frames early
Implemented bonus hit chance for Archery skill, based on mention of such a bonus in Publish 5 patch notes and related UO House of Commons chat. This has been exposed as a UOX.INI setting where this bonus can be tweaked:
	ARCHERYHITBONUS=10 	// Bonus hit chance for Archery skill added to regular hit chance in combat. Defaults to 10%
Implemented optional extra delay between moving and being able to shoot with ranged weapons in combat (in addition to whatever delay is there due to speed of the ranged weapon). This is exposed as a UOX.INI setting:
	ARCHERYSHOOTDELAY=0.5 // Minimum delay in seconds from a player stops moving until they can start to fire their ranged weapon. Defaults to 0.5s
Fixed a bug where players who never entered combat mode could fire ranged weapons while moving
Updated Add-menu with some improvements for usability:
	Menu now directly on the Objects (previously "Shard") tab for quicker access, with a small welcome text and quick-link button for UOX3 docs
	Settings tab contains some (persistent, will be saved with character) options for how the Add-menu behaves, along with a few quick-access buttons to some useful commands. Available options:
		Option to add chosen item at specific location instead of in GM's backpack
		Option to add chosen item repeatedly until cancelled
		Option to automatically reopen Add-menu on last menu that was open when a selection is made
		Option to force decayable state of all added items to either off (doesn't decay), on (decays) or nothing (use item default)
		Option to force movable state of all added items to either off (not movable), on (movable) or nothing (use item default)
	Added a Home button at the bottom of the menu, that takes the user back to the front page of the Add-menu regardless of which menu page they're on
Updated Character/Socket JS Method SysMessage() with an optional parameter to specify the color used to display the system message. Updated syntax:
	.SysMessage( "Text" ) 									// Display "Text" to user as a system message with default system message color from ini
	.SysMessage( "Text %s %s", txtArg1, txtArg2 ) 			// Display "Text" to player with string arguments injected into text
	.SysMessage( txtColor, "Text" ) 						// Display "Text" to user with a specified color
	.SysMessage( txtColor, "Text %s %s", txtArg1, txtArg2 ) // Combination of text color, text and string arguments
Fixed a bug where hair/beard items could show up inside corpses
Fixed a bug where items could sometimes vanish (visually) from containers when bouncing back because player was not able to pick them up
Fixed a bug where players would be unable to pick up a freely movable item from a locked down container
Updated handling of item bouncing on pickup to use UOX3 dictionary messages instead of hard-coded client messages
Added support for new Dictionary language:
	dictionary.POL - Polish (SERVERLANGUAGE=8 in uox.ini, or client language 83 if SERVERLANGUAGE is set to 0)
Added taming restrictions for Unicorn, Ki-Rin and Cu Sidhe (js/skill/taming.js)
Added modification of some creatures stats after they've been tamed (js/skill/taming.js)
Added restrictions for who can ride certain creatures (Unicorn, Ki-Rin, Cu Sidhe)
Updated words of power for Meteor Swarm spell to follow the same logic as other spells using Kal (Summon): Kal Des Flam Ylem
Added new Item/Character JS Methods to get/set temporary custom tags which don't persist across worldsaves (or across reconnects, for players):
	.GetTempTag( "tagName" )
	.SetTempTag( "tagName", tagValue )
When applying HPMAX, STAMINAMAX AND MANAMAX DFN tags to new NPCs, their current HP, STAMINA and MANA properties will now be automatically updated to match
Fixed a server crash caused by empty speech messages sent from certain clients
Fixed a bug that prevented teleport locations in Felucca/Trammel from working properly
Updated calculations in code for duration and damage of existing poison strengths (1 - Lesser, 2 - Normal, 3 - Greater, 4 - Deadly) to match with ~Publish 15 (LBR/pre-AoS), and added another poison strength for monster usage (5 - Lethal)
The strength of the Poison and Poison Field spells is now based on the average of the caster's Magery and Poisoning skills, the distance from the target (Poison spell only) and the target's Resisting Spells skill. If caster is further away than 2 tiles from target, the poison strength always equals Lesser Poison, otherwise the following rules apply:
	If caster's combined skill is higher than 100.0, poison strength equals Greater Poison, with 5% chance of Deadly Poison (if Poison spell) or Deadly Poison (if Poison Field spell)
	If caster's combined skill is higher than 70.2, poison strength equals Greater Poison
	If caster's combined skill is higher than 30.2, poison strength equals Normal Poison
	If caster's combined skill is 30.2 or lower, poison strength equals Lesser Poison
	If target resists spell, poison strength is reduced by 1 level, unless it's already at the lowest level
Fixed an issue that would would let players move faster than they should have been allowed to
Fixed misc issues with Party System:
	Mana and Stamina should now update for Party Members when added to the party, when going in/out of range and when their stats update while in range
	Players who get disconnected or relog should now find themselves back in the same party they were in previously
	Added system messages to inform party members about updates to their party, and to let invited players know they've successfully joined a party (or rejoined, if relogging)
World saves now operate on the principle of only saving changes done since the last world save. Combined with the fact that NPCs in UOX3 are only active if there are players in the same/neighbouring map regions, shard owners may expect to see a decrease in world save times ranging from ~11% to ~99%, depending on how active and how spread out their player base is. If no changes have taken place since last save, saves are virtually instantaneous!
2021-09-20 21:35:17 +08:00

2196 lines
83 KiB
C++

#include "uox3.h"
#include "cWeather.hpp"
#include "townregion.h"
#include "cRaces.h"
#include "cServerDefinitions.h"
#include "ssection.h"
#include "cEffects.h"
#include "CPacketSend.h"
#include "scriptc.h"
#include "mapstuff.h"
#include "cScript.h"
#include "CJSMapping.h"
#include "combat.h"
#define EFFECTIVE 2
const UI08 MAXVAL = 0;
const UI08 MINVAL = 1;
const UI08 CURRVAL = 2;
const UI08 TEMP = 0;
const UI08 WIND = 1;
cWeatherAb *Weather = nullptr;
// Version History
// 1.0 Unknown
// Initial implementation
// Based on a weatherSys structure system
// 2.0 11th April, 2001
// Rewritten system
// Each weather sys is a CWeather class
// PeriodicUpdate for CWeather also updates light level
// cWeatherAb simplified to access CWeather containers
// Replaced a new'd array with a vector of CWeather
CWeather::CWeather()
{
memset( weather, 0, sizeof( WeathPart ) * WEATHNUM );
ColdChance( 5 );
RainChance( 10 );
SnowChance( 1 );
HeatChance( 10 );
StormChance( 1 );
LightMin( 300 );
LightMax( 300 );
CurrentLight( 300 );
MaxTemp( 30 );
MinTemp( 5 );
RainTempDrop( 5 );
StormTempDrop( 10 );
ColdIntensityHigh( 0 );
HeatIntensityHigh( 35 );
StormIntensityHigh( 100 );
SnowIntensityHigh( 100 );
RainIntensityHigh( 100 );
StormIntensityLow( 0 );
SnowIntensityLow( 0 );
RainIntensityLow( 0 );
StormIntensity( 0 );
SnowIntensity( 0 );
RainIntensity( 0 );
Temp( 15 );
MaxWindSpeed( 0 );
MinWindSpeed( 0 );
WindSpeed( 0 );
SnowThreshold( 15.0f );
}
CWeather::~CWeather()
{
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool HeatActive( void ) const
//| void HeatActive( bool value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether the weather system is having a heat wave
//o-----------------------------------------------------------------------------------------------o
bool CWeather::HeatActive( void ) const
{
return weather[HEAT].Active;
}
void CWeather::HeatActive( bool value )
{
weather[HEAT].Active = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool ColdActive( void ) const
//| void ColdActive( bool value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/sets whether the weather system is having a cold snap
//o-----------------------------------------------------------------------------------------------o
bool CWeather::ColdActive( void ) const
{
return weather[COLD].Active;
}
void CWeather::ColdActive( bool value )
{
weather[COLD].Active = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 CurrentLight( void ) const
//| void CurrentLight( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the current light level of the system, IF
//| LightMin and LightMax are less than 300
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::CurrentLight( void ) const
{
return light[CURRVAL];
}
void CWeather::CurrentLight( R32 value )
{
light[CURRVAL] = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool PeriodicUpdate( void )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Updates the current light level of the system and the current temperature of
//| the system. Wind is not currently updated
//o-----------------------------------------------------------------------------------------------o
bool CWeather::PeriodicUpdate( void )
{
R32 currTemp;
UI08 hour = cwmWorldState->ServerData()->ServerTimeHours();
UI08 minute = cwmWorldState->ServerData()->ServerTimeMinutes();
bool ampm = cwmWorldState->ServerData()->ServerTimeAMPM();
if( StormDelay() && StormBrewing() )
StormActive( true );
else if( StormBrewing() )
StormDelay( true );
if( LightMin() < 300 && LightMax() < 300 )
{
R32 hourIncrement = static_cast<R32>(fabs( ( LightMax() - LightMin() ) / 12.0f )); // we want the amount to subtract from LightMax in the morning / add to LightMin in evening
R32 minuteIncrement = hourIncrement / 60.0f;
R32 tempLight = hourIncrement * (R32)hour + minuteIncrement * (R32)minute;
if( ampm )
CurrentLight( LightMin() + tempLight );
else
CurrentLight( LightMax() - tempLight );
}
R32 effTempMax = EffectiveMaxTemp();
R32 effTempMin = EffectiveMinTemp();
R32 tempHourIncrement = static_cast<R32>(fabs( ( effTempMax - effTempMin ) / 12.0f ));
R32 tempMinuteIncrement = tempHourIncrement / 60.0f;
R32 tempLightChange = tempHourIncrement * (R32)hour + tempMinuteIncrement * (R32)minute;
if( ampm )
currTemp = effTempMax - tempLightChange; // maximum temperature minus time
else
currTemp = effTempMin + tempLightChange; // minimum temperature plus time
if( StormActive() )
{
currTemp -= StormTempDrop();
if ( currTemp < 0 )
currTemp = 0;
}
else if( RainActive() )
{
currTemp -= RainTempDrop();
if ( currTemp < 0 )
currTemp = 0;
}
Temp( currTemp );
return true;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void NewDay( void )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the system up for a new day. Heat wave, cold snap are calculated
//o-----------------------------------------------------------------------------------------------o
void CWeather::NewDay( void )
{
bool isHeatWave = false, isColdDay = false;
R32 effTempMax = MaxTemp();
R32 effTempMin = MinTemp();
R32 currentTemp;
if( (UI08)RandomNum( 0, 100 ) <= HeatChance() )
{
isHeatWave = true;
currentTemp = RandomNum( (SI32)effTempMax, (SI32)HeatIntensityHigh() );
effTempMax = currentTemp;
effTempMin = currentTemp;
}
else if( (UI08)RandomNum( 0, 100 ) <= ColdChance() )
{
isColdDay = true;
currentTemp = RandomNum( (SI32)ColdIntensityHigh(), (SI32)effTempMin );
effTempMax = currentTemp;
effTempMin = currentTemp;
}
HeatActive( isHeatWave );
ColdActive( isColdDay );
EffectiveMaxTemp( effTempMax );
EffectiveMinTemp( effTempMin );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void NewHour( void )
//| Date - 16th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Calculates rain, snow and storm changes.
//o-----------------------------------------------------------------------------------------------o
void CWeather::NewHour( void )
{
bool isSnowing = false, isRaining = false, isStorm = false;
if( (UI08)RandomNum( 0, 100 ) <= StormChance() )
{
isStorm = true;
}
if( (UI08)RandomNum( 0, 100 ) <= SnowChance() )
{
isSnowing = true;
}
if( (UI08)RandomNum( 0, 100 ) <= RainChance() )
{
isRaining = true;
}
if( !isStorm ) {
StormDelay( false );
StormActive( false );
}
//Calculate intensity values for the weather types
RainIntensity( (SI08)RandomNum( static_cast<std::int16_t>(RainIntensityLow()), static_cast<std::int16_t>(RainIntensityHigh()) ) );
SnowIntensity( (SI08)RandomNum( static_cast<std::int16_t>(SnowIntensityLow()), static_cast<std::int16_t>(SnowIntensityHigh())) );
StormIntensity( (SI08)RandomNum( static_cast<std::int16_t>(StormIntensityLow()), static_cast<std::int16_t>(StormIntensityHigh()) ) );
SnowActive( isSnowing );
RainActive( isRaining );
StormBrewing( isStorm );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 IntensityHigh( UI08 weathType ) const
//| SI08 IntensityLow( UI08 weathType ) const
//| SI08 Intensity( UI08 weathType ) const
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the intensity of the weather weathType
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::IntensityHigh( UI08 weathType ) const
{
return weather[weathType].IntensityHigh;
}
SI08 CWeather::IntensityLow( UI08 weathType ) const
{
return weather[weathType].IntensityLow;
}
SI08 CWeather::Intensity( UI08 weathType ) const
{
return weather[weathType].Intensity;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void IntensityHigh( UI08 weathType, SI08 value )
//| void IntensityLow( UI08 weathType, SI08 value )
//| void Intensity( UI08 weathType, SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the intensity of weather weathType to value
//o-----------------------------------------------------------------------------------------------o
void CWeather::IntensityHigh( UI08 weathType, SI08 value )
{
weather[weathType].IntensityHigh = value;
}
void CWeather::IntensityLow( UI08 weathType, SI08 value )
{
weather[weathType].IntensityLow = value;
}
void CWeather::Intensity( UI08 weathType, SI08 value )
{
weather[weathType].Intensity = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 Chance( UI08 weathType ) const
//| void Chance( UI08 weathType, SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the chance of weather weathType occurring
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::Chance( UI08 weathType ) const
{
return weather[weathType].Chance;
}
void CWeather::Chance( UI08 weathType, SI08 value )
{
weather[weathType].Chance = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 Value( UI08 valType, UI08 valOff ) const
//| void Value( UI08 valType, UI08 valOff, R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the value associated with valType and valOff
//| valType is either MAXVAL, MINVAL, or CURRVAL
//| valOff is either WIND, TEMP or EFFECTIVE
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::Value( UI08 valType, UI08 valOff ) const
{
return assortVals[valType][valOff];
}
void CWeather::Value( UI08 valType, UI08 valOff, R32 value )
{
assortVals[valType][valOff] = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 SnowIntensityHigh( void ) const
//| SI08 SnowIntensityLow( void ) const
//| SI08 SnowIntensity( void ) const
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the intensity of the snow (if any)
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::SnowIntensityHigh( void ) const
{
return weather[SNOW].IntensityHigh;
}
SI08 CWeather::SnowIntensityLow( void ) const
{
return weather[SNOW].IntensityLow;
}
SI08 CWeather::SnowIntensity( void ) const
{
return weather[SNOW].Intensity;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 RainIntensityHigh( void ) const
//| SI08 RainIntensityLow( void ) const
//| SI08 RainIntensity( void ) const
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the intensity of the rain, if any
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::RainIntensityHigh( void ) const
{
return weather[RAIN].IntensityHigh;
}
SI08 CWeather::RainIntensityLow( void ) const
{
return weather[RAIN].IntensityLow;
}
SI08 CWeather::RainIntensity( void ) const
{
return weather[RAIN].Intensity;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 StormIntensityHigh( void ) const
//| SI08 StormIntensityLow( void ) const
//| SI08 StormIntensity( void ) const
//| Date - 16th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the intensity of the storm, if any
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::StormIntensityHigh( void ) const
{
return weather[STORM].IntensityHigh;
}
SI08 CWeather::StormIntensityLow( void ) const
{
return weather[STORM].IntensityLow;
}
SI08 CWeather::StormIntensity( void ) const
{
return weather[STORM].Intensity;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 HeatIntensityHigh( void ) const
//| void HeatIntensityHigh( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the heat intensity of the weather system
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::HeatIntensityHigh( void ) const
{
return weather[HEAT].IntensityHigh;
}
void CWeather::HeatIntensityHigh( SI08 value )
{
weather[HEAT].IntensityHigh = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 ColdIntensityHigh( void ) const
//| void ColdIntensityHigh( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the cold intensity of the weather system
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::ColdIntensityHigh( void ) const
{
return weather[COLD].IntensityHigh;
}
void CWeather::ColdIntensityHigh( SI08 value )
{
weather[COLD].IntensityHigh = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MaxTemp( void ) const
//| void MaxTemp( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the maximum temperature of the day (non effective)
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::MaxTemp( void ) const
{
return Value( MAXVAL, TEMP );
}
void CWeather::MaxTemp( R32 value )
{
Value( MAXVAL, TEMP, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MinTemp( void ) const
//| void MinTemp( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the minimum temperature of the day (non effective)
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::MinTemp( void ) const
{
return Value( MINVAL, TEMP );
}
void CWeather::MinTemp( R32 value )
{
Value( MINVAL, TEMP, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 Temp( void ) const
//| void Temp( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the current temperature of the day
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::Temp( void ) const
{
return Value( CURRVAL, TEMP );
}
void CWeather::Temp( R32 value )
{
Value( CURRVAL, TEMP, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 RainTempDrop( void ) const
//| void RainTempDrop( R32 value )
//| Date - 19th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the amount the temperature drops when it rains
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::RainTempDrop( void ) const
{
return rainTempDrop;
}
void CWeather::RainTempDrop( R32 value )
{
rainTempDrop = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 StormTempDrop( void ) const
//| void StormTempDrop( R32 value )
//| Date - 19th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the amount the temperature drops when it storms
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::StormTempDrop( void ) const
{
return stormTempDrop;
}
void CWeather::StormTempDrop( R32 value )
{
stormTempDrop = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MaxWindSpeed( void ) const
//| void MaxWindSpeed( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the maximum wind speed for the day
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::MaxWindSpeed( void ) const
{
return Value( MAXVAL, WIND );
}
void CWeather::MaxWindSpeed( R32 value )
{
Value( MAXVAL, WIND, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MinWindSpeed( void ) const
//| void MinWindSpeed( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the minimum wind speed for the day
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::MinWindSpeed( void ) const
{
return Value( MINVAL, WIND );
}
void CWeather::MinWindSpeed( R32 value )
{
Value( MINVAL, WIND, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 WindSpeed( void ) const
//| void WindSpeed( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the current wind speed
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::WindSpeed( void ) const
{
return Value( CURRVAL, WIND );
}
void CWeather::WindSpeed( R32 value )
{
Value( CURRVAL, WIND, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 RainChance( void ) const
//| void RainChance( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the chance of rain for the day
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::RainChance( void ) const
{
return weather[RAIN].Chance;
}
void CWeather::RainChance( SI08 value )
{
weather[RAIN].Chance = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 SnowChance( void ) const
//| void SnowChance( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the chance of snow for the day
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::SnowChance( void ) const
{
return weather[SNOW].Chance;
}
void CWeather::SnowChance( SI08 value )
{
weather[SNOW].Chance = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 StormChance( void ) const
//| void StormChance( SI08 value )
//| Date - 16th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the chance of storm for the day
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::StormChance( void ) const
{
return weather[STORM].Chance;
}
void CWeather::StormChance( SI08 value )
{
weather[STORM].Chance = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 HeatChance( void ) const
//| void HeatChance( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the chance of a heat wave for the day
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::HeatChance( void ) const
{
return weather[HEAT].Chance;
}
void CWeather::HeatChance( SI08 value )
{
weather[HEAT].Chance = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 ColdChance( void ) const
//| void ColdChance( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the chance of a cold snap for the day
//o-----------------------------------------------------------------------------------------------o
SI08 CWeather::ColdChance( void ) const
{
return weather[COLD].Chance;
}
void CWeather::ColdChance( SI08 value )
{
weather[COLD].Chance = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 LightMin( void ) const
//| void LightMin( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the minimum light level for the day (brightest)
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::LightMin( void ) const
{
return light[MINVAL];
}
void CWeather::LightMin( R32 value )
{
light[MINVAL] = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 LightMax( void ) const
//| void LightMax( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the maximum light level for the day (darkest)
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::LightMax( void ) const
{
return light[MAXVAL];
}
void CWeather::LightMax( R32 value )
{
light[MAXVAL] = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool RainActive( void ) const
//| void RainActive( bool value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether the weather system is raining
//o-----------------------------------------------------------------------------------------------o
bool CWeather::RainActive( void ) const
{
return weather[RAIN].Active;
}
void CWeather::RainActive( bool value )
{
weather[RAIN].Active = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool SnowActive( void ) const
//| void SnowActive( bool value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether the weather system is snowing
//o-----------------------------------------------------------------------------------------------o
bool CWeather::SnowActive( void ) const
{
return weather[SNOW].Active;
}
void CWeather::SnowActive( bool value )
{
weather[SNOW].Active = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool StormBrewing( void ) const
//| void StormBrewing( bool value )
//| Date - 16th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether the weather system is brewing a storm
//o-----------------------------------------------------------------------------------------------o
bool CWeather::StormBrewing( void ) const
{
return weather[STORMBREW].Active;
}
void CWeather::StormBrewing( bool value )
{
weather[STORMBREW].Active = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool StormActive( void ) const
//| void StormActive( bool value )
//| Date - 16th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether a storm is active in the weather system
//o-----------------------------------------------------------------------------------------------o
bool CWeather::StormActive( void ) const
{
return weather[STORM].Active;
}
void CWeather::StormActive( bool value )
{
weather[STORM].Active = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool StormDelay( void ) const
//| void StormDelay( bool value )
//| Date - 17th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether there is a storm delay in the weather system
//o-----------------------------------------------------------------------------------------------o
bool CWeather::StormDelay( void ) const
{
return stormDelay;
}
void CWeather::StormDelay( bool value )
{
stormDelay = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 SnowThreshold( void ) const
//| void SnowThreshold( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the temperature below which snow kicks in
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::SnowThreshold( void ) const
{
return snowThreshold;
}
void CWeather::SnowThreshold( R32 value )
{
snowThreshold = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void SnowIntensityHigh( SI08 value )
//| void SnowIntensityLow( SI08 value )
//| void SnowIntensity( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the snow intensity of the system
//o-----------------------------------------------------------------------------------------------o
void CWeather::SnowIntensityHigh( SI08 value )
{
weather[SNOW].IntensityHigh = value;
}
void CWeather::SnowIntensityLow( SI08 value )
{
weather[SNOW].IntensityLow = value;
}
void CWeather::SnowIntensity( SI08 value )
{
weather[SNOW].Intensity = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void StormIntensityHigh( SI08 value )
//| void StormIntensityLow( SI08 value )
//| void StormIntensity( SI08 value )
//| Date - 16th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the storm intensity of the system
//o-----------------------------------------------------------------------------------------------o
void CWeather::StormIntensityHigh( SI08 value )
{
weather[STORM].IntensityHigh = value;
}
void CWeather::StormIntensityLow( SI08 value )
{
weather[STORM].IntensityLow = value;
}
void CWeather::StormIntensity( SI08 value )
{
weather[STORM].Intensity = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void RainIntensityHigh( SI08 value )
//| void RainIntensityLow( SI08 value )
//| void RainIntensity( SI08 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the rain intensity of the system
//o-----------------------------------------------------------------------------------------------o
void CWeather::RainIntensityHigh( SI08 value )
{
weather[RAIN].IntensityHigh = value;
}
void CWeather::RainIntensityLow( SI08 value )
{
weather[RAIN].IntensityLow = value;
}
void CWeather::RainIntensity( SI08 value )
{
weather[RAIN].Intensity = value;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 EffectiveMaxTemp( void ) const
//| void EffectiveMaxTemp( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the effective maximum temperature for the day
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::EffectiveMaxTemp( void ) const
{
return Value( MAXVAL, EFFECTIVE );
}
void CWeather::EffectiveMaxTemp( R32 value )
{
Value( MAXVAL, EFFECTIVE, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 EffectiveMinTemp( void ) const
//| void EffectiveMinTemp( R32 value )
//| Date - 11th April, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the effective minimum temperature for the day
//o-----------------------------------------------------------------------------------------------o
R32 CWeather::EffectiveMinTemp( void ) const
{
return Value( MINVAL, EFFECTIVE );
}
void CWeather::EffectiveMinTemp( R32 value )
{
Value( MINVAL, EFFECTIVE, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - cWeatherAb()
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Default weather constructor
//o-----------------------------------------------------------------------------------------------o
cWeatherAb::cWeatherAb()
{
weather.resize( 0 );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - ~cWeatherAb()
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Destroys any allocated memory
//o-----------------------------------------------------------------------------------------------o
cWeatherAb::~cWeatherAb()
{
weather.clear();
}
//o-----------------------------------------------------------------------------------------------o
//| Function - size_t Count( void ) const
//| Date - 31st July, 2001
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns count of weather systems
//o-----------------------------------------------------------------------------------------------o
size_t cWeatherAb::Count( void ) const
{
return weather.size();
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool Load( void ) const
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns true if the weather system loaded okay
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::Load( void )
{
weather.resize( FileLookup->CountOfEntries( weathab_def ) );
std::string tag, data, UTag;
std::string entryName;
size_t i = 0;
for( Script *weathScp = FileLookup->FirstScript( weathab_def ); !FileLookup->FinishedScripts( weathab_def ); weathScp = FileLookup->NextScript( weathab_def ) )
{
if( weathScp == nullptr )
continue;
for( ScriptSection *WeatherStuff = weathScp->FirstEntry(); WeatherStuff != nullptr; WeatherStuff = weathScp->NextEntry() )
{
if( WeatherStuff == nullptr )
{
continue;
}
entryName = weathScp->EntryName();
auto ssecs = strutil::sections( entryName, " " );
i = static_cast<UI32>(std::stoul(ssecs[1], nullptr, 0));
if( i >= weather.size() )
{
weather.resize( i+1 );
}
for( tag = WeatherStuff->First(); !WeatherStuff->AtEnd(); tag = WeatherStuff->Next() )
{
UTag = strutil::upper( tag );
data = WeatherStuff->GrabData();
switch( tag[0] )
{
case 'c':
case 'C':
if( UTag == "COLDCHANCE" ) // chance for a cold day
{
ColdChance( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
else if( UTag == "COLDINTENSITY" ) // cold intensity
{
ColdIntensityHigh( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
break;
case 'h':
case 'H':
if( UTag == "HEATCHANCE" ) // chance for a hot day
{
HeatChance( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
else if( UTag == "HEATINTENSITY" ) // heat intensity
{
HeatIntensityHigh( static_cast<weathID>(i),static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
break;
case 'l':
case 'L':
if( UTag == "LIGHTMIN" ) // minimum light level
{
LightMin( static_cast<weathID>(i), std::stof(data) );
}
else if( UTag == "LIGHTMAX" ) // maximum light level
{
LightMax( static_cast<weathID>(i), std::stof(data));
}
break;
case 'm':
case 'M':
if( UTag == "MAXTEMP" ) // maximum temperature
{
MaxTemp( static_cast<weathID>(i), std::stof(data) );
}
else if( UTag == "MINTEMP" ) // minimum temperature
{
MinTemp( static_cast<weathID>(i), std::stof(data) );
}
else if( UTag == "MAXWIND" ) // maximum wind speed
{
MaxWindSpeed( static_cast<weathID>(i), std::stof(data) );
}
else if( UTag == "MINWIND" ) // minimum wind speed
{
MinWindSpeed( static_cast<weathID>(i), std::stof(data) );
}
break;
case 'r':
case 'R':
if( UTag == "RAINCHANCE" ) // chance of rain
{
RainChance( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
else if( UTag == "RAININTENSITY" ) // intensity of rain
{
auto csecs = strutil::sections( data, "," );
if( csecs.size() > 1 )
{
RainIntensityLow( static_cast<weathID>(i), static_cast<SI08>(std::stoi(strutil::trim( strutil::removeTrailing( csecs[0], "//" )),nullptr,0)) );
RainIntensityHigh( static_cast<weathID>(i), static_cast<SI08>(std::stoi(strutil::trim( strutil::removeTrailing( csecs[1], "//" )),nullptr,0)) );
}
else
{
RainIntensityLow( static_cast<weathID>(i), 0 );
RainIntensityHigh( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
}
else if( UTag == "RAINTEMPDROP" ) // temp drop of rain
{
RainTempDrop( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
break;
case 's':
case 'S':
if( UTag == "SNOWCHANCE" ) // chance of snow
{
SnowChance( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
else if( UTag == "SNOWINTENSITY" ) // intensity of snow
{
auto csecs = strutil::sections( data, "," );
if( csecs.size() > 1 )
{
SnowIntensityLow( static_cast<weathID>(i), static_cast<SI08>(std::stoi(strutil::trim( strutil::removeTrailing( csecs[0], "//" )),nullptr,0)));
SnowIntensityHigh( static_cast<weathID>(i), static_cast<SI08>(std::stoi(strutil::trim( strutil::removeTrailing( csecs[1], "//" )),nullptr,0)));
}
else
{
SnowIntensityLow( static_cast<weathID>(i), 0 );
SnowIntensityHigh( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
}
else if( UTag == "SNOWTHRESHOLD" ) // temperature at which snow kicks in
{
SnowThreshold( static_cast<weathID>(i), std::stof(data) );
}
else if( UTag == "STORMCHANCE" ) // chance of a storm
{
StormChance( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
else if( UTag == "STORMINTENSITY" ) // chance of a storm
{
auto csecs = strutil::sections( data, "," );
if( csecs.size() > 1 )
{
SnowIntensityLow( static_cast<weathID>(i), static_cast<SI08>(std::stoi(strutil::trim( strutil::removeTrailing( csecs[0], "//" )),nullptr,0)));
SnowIntensityHigh( static_cast<weathID>(i), static_cast<SI08>(std::stoi(strutil::trim( strutil::removeTrailing( csecs[1], "//" )),nullptr,0)));
}
else
{
SnowIntensityLow( static_cast<weathID>(i), 0 );
SnowIntensityHigh( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
}
else if( UTag == "STORMTEMPDROP" ) // temp drop of storm
{
StormTempDrop( static_cast<weathID>(i), static_cast<SI08>(std::stoi(data, nullptr, 0)) );
}
break;
}
}
}
}
return true;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 IntensityHigh( weathID toCheck, UI08 weathType )
//| SI08 IntensityLow( weathID toCheck, UI08 weathType )
//| SI08 Intensity( weathID toCheck, UI08 weathType )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Helper func to return intensity of a weather type
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::IntensityHigh( weathID toCheck, UI08 weathType )
{
return weather[toCheck].IntensityHigh( weathType );
}
SI08 cWeatherAb::IntensityLow( weathID toCheck, UI08 weathType )
{
return weather[toCheck].IntensityLow( weathType );
}
SI08 cWeatherAb::Intensity( weathID toCheck, UI08 weathType )
{
return weather[toCheck].Intensity( weathType );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void IntensityHigh( weathID toCheck, UI08 weathType, SI08 value )
//| void IntensityLow( weathID toCheck, UI08 weathType, SI08 value )
//| void Intensity( weathID toCheck, UI08 weathType, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Helper func to set the intensity of a particular weather type
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::IntensityHigh( weathID toCheck, UI08 weathType, SI08 value )
{
weather[toCheck].IntensityHigh( weathType, value );
}
void cWeatherAb::IntensityLow( weathID toCheck, UI08 weathType, SI08 value )
{
weather[toCheck].IntensityLow( weathType, value );
}
void cWeatherAb::Intensity( weathID toCheck, UI08 weathType, SI08 value )
{
weather[toCheck].Intensity( weathType, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 Chance( weathID toCheck, UI08 weathType )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Helper func to return chance of a weather type
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::Chance( weathID toCheck, UI08 weathType )
{
return weather[toCheck].Chance( weathType );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void Chance( weathID toCheck, UI08 weathType, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Helper func to set the chance of finding a weather type
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::Chance( weathID toCheck, UI08 weathType, SI08 value )
{
weather[toCheck].Chance( weathType, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 Value( weathID toCheck, UI08 valType, UI08 valOff )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Helper func to return value of some weather types
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::Value( weathID toCheck, UI08 valType, UI08 valOff )
// PRE: toCheck is valid, valType is valid, valOff is valid
// POST: returns value of valType and valOff in toCheck
{
return weather[toCheck].Value( valType, valOff );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void Value( weathID toCheck, UI08 valType, UI08 valOff, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Helper func to set the value of a particular weather type
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::Value( weathID toCheck, UI08 valType, UI08 valOff, R32 value )
// PRE: toCheck is valid, valType and valOff is valid, value is valid
// POST: value of valType and valOff in toCheck is value
{
weather[toCheck].Value( valType, valOff, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 SnowIntensityHigh( weathID toCheck )
//| SI08 SnowIntensityLow( weathID toCheck )
//| SI08 SnowIntensity( weathID toCheck )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the intensity of toCheck's snow
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::SnowIntensityHigh( weathID toCheck )
{
return IntensityHigh( toCheck, SNOW );
}
SI08 cWeatherAb::SnowIntensityLow( weathID toCheck )
{
return IntensityLow( toCheck, SNOW );
}
SI08 cWeatherAb::SnowIntensity( weathID toCheck )
{
return Intensity( toCheck, SNOW );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 StormIntensityHigh( weathID toCheck )
//| SI08 StormIntensityLow( weathID toCheck )
//| SI08 StormIntensity( weathID toCheck )
//| Date - 16th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the intensity of toCheck's storm
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::StormIntensityHigh( weathID toCheck )
{
return IntensityHigh( toCheck, STORM );
}
SI08 cWeatherAb::StormIntensityLow( weathID toCheck )
{
return IntensityLow( toCheck, STORM );
}
SI08 cWeatherAb::StormIntensity( weathID toCheck )
{
return Intensity( toCheck, STORM );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 RainIntensityHigh( weathID toCheck )
//| SI08 RainIntensityLow( weathID toCheck )
//| SI08 RainIntensity( weathID toCheck )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Returns the intensity of toCheck's rain
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::RainIntensityHigh( weathID toCheck )
{
return IntensityHigh( toCheck, RAIN );
}
SI08 cWeatherAb::RainIntensityLow( weathID toCheck )
{
return IntensityLow( toCheck, RAIN );
}
SI08 cWeatherAb::RainIntensity( weathID toCheck )
{
return Intensity( toCheck, RAIN );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 HeatIntensityHigh( weathID toCheck )
//| void HeatIntensityHigh( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the high intensity of toCheck's heat
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::HeatIntensityHigh( weathID toCheck )
{
return IntensityHigh( toCheck, HEAT );
}
void cWeatherAb::HeatIntensityHigh( weathID toCheck, SI08 value )
{
IntensityHigh( toCheck, HEAT, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 ColdIntensityHigh( weathID toCheck )
//| void ColdIntensityHigh( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the high intensity of toCheck's cold
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::ColdIntensityHigh( weathID toCheck )
{
return IntensityHigh( toCheck, COLD );
}
void cWeatherAb::ColdIntensityHigh( weathID toCheck, SI08 value )
{
IntensityHigh( toCheck, COLD, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MaxTemp( weathID toCheck )
//| void MaxTemp( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the maximum temperature of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::MaxTemp( weathID toCheck )
{
return Value( toCheck, MAXVAL, TEMP );
}
void cWeatherAb::MaxTemp( weathID toCheck, R32 value )
{
Value( toCheck, MAXVAL, TEMP, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MinTemp( weathID toCheck )
//| void MinTemp( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the minimum temperature of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::MinTemp( weathID toCheck )
{
return Value( toCheck, MINVAL, TEMP );
}
void cWeatherAb::MinTemp( weathID toCheck, R32 value )
{
Value( toCheck, MINVAL, TEMP, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 Temp( weathID toCheck )
//| void Temp( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the temperature of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::Temp( weathID toCheck )
{
return Value( toCheck, CURRVAL, TEMP );
}
void cWeatherAb::Temp( weathID toCheck, R32 value )
{
Value( toCheck, CURRVAL, TEMP, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 RainTempDrop( weathID toCheck )
//| void RainTempDrop( weathID toCheck, R32 value )
//| Date - 19th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the rain temperature drop of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::RainTempDrop( weathID toCheck )
{
return weather[toCheck].RainTempDrop();
}
void cWeatherAb::RainTempDrop( weathID toCheck, R32 value )
{
weather[toCheck].RainTempDrop( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 RainTempDrop( weathID toCheck )
//| void cWeatherAb::StormTempDrop( weathID toCheck, R32 value )
//| Date - 19th Feb, 2006
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the storm temperature drop of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::StormTempDrop( weathID toCheck )
{
return weather[toCheck].StormTempDrop();
}
void cWeatherAb::StormTempDrop( weathID toCheck, R32 value )
{
weather[toCheck].StormTempDrop( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MaxWindSpeed( weathID toCheck )
//| void MaxWindSpeed( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the maximum wind speed of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::MaxWindSpeed( weathID toCheck )
{
return Value( toCheck, MAXVAL, WIND );
}
void cWeatherAb::MaxWindSpeed( weathID toCheck, R32 value )
{
Value( toCheck, MAXVAL, WIND, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 MinWindSpeed( weathID toCheck )
//| void MinWindSpeed( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the minimum wind speed of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::MinWindSpeed( weathID toCheck )
{
return Value( toCheck, MINVAL, WIND );
}
void cWeatherAb::MinWindSpeed( weathID toCheck, R32 value )
{
Value( toCheck, MINVAL, WIND, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 WindSpeed( weathID toCheck )
//| void WindSpeed( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the wind speed of toCheck
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::WindSpeed( weathID toCheck )
{
return Value( toCheck, CURRVAL, WIND );
}
void cWeatherAb::WindSpeed( weathID toCheck, R32 value )
{
Value( toCheck, CURRVAL, WIND, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void SnowIntensityHigh( weathID toCheck, SI08 value )
//| void SnowIntensityLow( weathID toCheck, SI08 value )
//| void SnowIntensity( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the intensity of toCheck's snow
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::SnowIntensityHigh( weathID toCheck, SI08 value )
{
IntensityHigh( toCheck, SNOW, value );
}
void cWeatherAb::SnowIntensityLow( weathID toCheck, SI08 value )
{
IntensityLow( toCheck, SNOW, value );
}
void cWeatherAb::SnowIntensity( weathID toCheck, SI08 value )
{
Intensity( toCheck, SNOW, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void StormIntensityHigh( weathID toCheck, SI08 value )
//| void StormIntensityLow( weathID toCheck, SI08 value )
//| void StormIntensity( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the intensity of toCheck's storm
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::StormIntensityHigh( weathID toCheck, SI08 value )
{
IntensityHigh( toCheck, STORM, value );
}
void cWeatherAb::StormIntensityLow( weathID toCheck, SI08 value )
{
IntensityLow( toCheck, STORM, value );
}
void cWeatherAb::StormIntensity( weathID toCheck, SI08 value )
{
Intensity( toCheck, STORM, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void RainIntensityHigh( weathID toCheck, SI08 value )
//| void RainIntensityLow( weathID toCheck, SI08 value )
//| void RainIntensity( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sets the intensity of toCheck's rain
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::RainIntensityHigh( weathID toCheck, SI08 value )
{
IntensityHigh( toCheck, RAIN, value );
}
void cWeatherAb::RainIntensityLow( weathID toCheck, SI08 value )
{
IntensityLow( toCheck, RAIN, value );
}
void cWeatherAb::RainIntensity( weathID toCheck, SI08 value )
{
Intensity( toCheck, RAIN, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 RainChance( weathID toCheck )
//| void RainChance( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets toCheck's rain chance
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::RainChance( weathID toCheck )
{
return Chance( toCheck, RAIN );
}
void cWeatherAb::RainChance( weathID toCheck, SI08 value )
{
Chance( toCheck, RAIN, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 SnowChance( weathID toCheck )
//| void SnowChance( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets toCheck's snow chance
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::SnowChance( weathID toCheck )
{
return Chance( toCheck, SNOW );
}
void cWeatherAb::SnowChance( weathID toCheck, SI08 value )
{
Chance( toCheck, SNOW, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 StormChance( weathID toCheck )
//| void StormChance( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets toCheck's storm chance
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::StormChance( weathID toCheck )
{
return Chance( toCheck, STORM );
}
void cWeatherAb::StormChance( weathID toCheck, SI08 value )
{
Chance( toCheck, STORM, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 HeatChance( weathID toCheck )
//| void HeatChance( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets toCheck's heat chance
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::HeatChance( weathID toCheck )
{
return Chance( toCheck, HEAT );
}
void cWeatherAb::HeatChance( weathID toCheck, SI08 value )
{
Chance( toCheck, HEAT, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - SI08 ColdChance( weathID toCheck )
//| void ColdChance( weathID toCheck, SI08 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets toCheck's cold chance
//o-----------------------------------------------------------------------------------------------o
SI08 cWeatherAb::ColdChance( weathID toCheck )
{
return Chance( toCheck, COLD );
}
void cWeatherAb::ColdChance( weathID toCheck, SI08 value )
{
Chance( toCheck, COLD, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 SnowThreshold( weathID toCheck )
//| void SnowThreshold( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets toCheck's snow threshold
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::SnowThreshold( weathID toCheck )
{
return weather[toCheck].SnowThreshold();
}
void cWeatherAb::SnowThreshold( weathID toCheck, R32 value )
{
weather[toCheck].SnowThreshold( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool NewDay( void )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Begins a new day in the weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::NewDay( void )
{
std::vector< CWeather >::iterator wIter;
for( wIter = weather.begin(); wIter != weather.end(); ++wIter )
(*wIter).NewDay();
return true;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool NewHour( void )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Begins a new hour in the weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::NewHour( void )
{
std::vector< CWeather >::iterator wIter;
for( wIter = weather.begin(); wIter != weather.end(); ++wIter )
(*wIter).NewHour();
return true;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 EffectiveMinTemp( weathID toCheck )
//| void EffectiveMinTemp( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the effective min temperature of a weather system
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::EffectiveMinTemp( weathID toCheck )
{
return Value( toCheck, MINVAL, EFFECTIVE );
}
void cWeatherAb::EffectiveMinTemp( weathID toCheck, R32 value )
{
Value( toCheck, MINVAL, EFFECTIVE, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 EffectiveMaxTemp( weathID toCheck )
//| void EffectiveMaxTemp( weathID toCheck, R32 value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the effective max temperature of a weather system
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::EffectiveMaxTemp( weathID toCheck )
{
return Value( toCheck, MAXVAL, EFFECTIVE );
}
void cWeatherAb::EffectiveMaxTemp( weathID toCheck, R32 value )
{
Value( toCheck, MAXVAL, EFFECTIVE, value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool DoStuff( void )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Periodically called from main loop to update weather types
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::DoStuff( void )
{
std::vector< CWeather >::iterator wIter;
for( wIter = weather.begin(); wIter != weather.end(); ++wIter )
(*wIter).PeriodicUpdate();
return true;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool HeatActive( weathID toCheck )
//| void HeatActive( weathID toCheck, bool value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets heat in specified weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::HeatActive( weathID toCheck )
{
return weather[toCheck].HeatActive();
}
void cWeatherAb::HeatActive( weathID toCheck, bool value )
{
weather[toCheck].HeatActive( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool ColdActive( weathID toCheck )
//| void ColdActive( weathID toCheck, bool value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets cold in specified weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::ColdActive( weathID toCheck )
{
return weather[toCheck].ColdActive();
}
void cWeatherAb::ColdActive( weathID toCheck, bool value )
{
weather[toCheck].ColdActive( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool RainActive( weathID toCheck )
//| void RainActive( weathID toCheck, bool value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets rain in specified weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::RainActive( weathID toCheck )
{
return weather[toCheck].RainActive();
}
void cWeatherAb::RainActive( weathID toCheck, bool value )
{
weather[toCheck].RainActive( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool SnowActive( weathID toCheck )
//| void SnowActive( weathID toCheck, bool value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets snow in specified weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::SnowActive( weathID toCheck )
{
return weather[toCheck].SnowActive();
}
void cWeatherAb::SnowActive( weathID toCheck, bool value )
{
weather[toCheck].SnowActive( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool StormBrewing( weathID toCheck )
//| void StormBrewing( weathID toCheck, bool value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether a storm is brewing in specified weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::StormBrewing( weathID toCheck )
{
return weather[toCheck].StormBrewing();
}
void cWeatherAb::StormBrewing( weathID toCheck, bool value )
{
weather[toCheck].StormBrewing( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool StormActive( weathID toCheck )
//| void StormActive( weathID toCheck, bool value )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets whether a storm is active in specified weather system
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::StormActive( weathID toCheck )
{
return weather[toCheck].StormActive();
}
void cWeatherAb::StormActive( weathID toCheck, bool value )
{
weather[toCheck].StormActive( value );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool DoPlayerStuff( CSocket *s, CChar *p )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Updates weather effects for players when light levels change,
//| or depending on whether player is inside or outside of buildings
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::DoPlayerStuff( CSocket *s, CChar *p )
{
if( !ValidateObject( p ) || p->IsNpc() )
return true;
weathID currval = p->GetRegion()->GetWeather();
if( currval > weather.size() || weather.empty() || p->inBuilding() )
{
if( s != nullptr )
{
CPWeather dry( 0xFF, 0x00, 0 );
s->Send( &dry );
if( p->GetWeathDamage( SNOW ) != 0 )
p->SetWeathDamage( 0, SNOW );
if( p->GetWeathDamage( STORM ) != 0 )
p->SetWeathDamage( 0, STORM );
if( p->GetWeathDamage( RAIN ) != 0 )
p->SetWeathDamage( 0, RAIN );
if( p->GetWeathDamage( COLD ) != 0 )
p->SetWeathDamage( 0, COLD );
if( p->GetWeathDamage( HEAT ) != 0 )
p->SetWeathDamage( 0, HEAT );
SendJSWeather( p, LIGHT, 0 );
}
return false;
}
bool isStorm = StormActive( currval );
bool brewStorm = StormBrewing( currval );
bool isSnowing = SnowActive( currval );
bool isRaining = RainActive( currval );
SI08 temp = (SI08)Temp( currval );
if( isStorm )
{
DoPlayerWeather( s, 5, temp, currval );
if( p->GetWeathDamage( STORM ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), STORM )) )), STORM );
if( p->GetWeathDamage( SNOW ) != 0 )
p->SetWeathDamage( 0, SNOW );
if( p->GetWeathDamage( RAIN ) != 0 )
p->SetWeathDamage( 0, RAIN );
SendJSWeather( p, STORM, temp );
}
else if( brewStorm )
{
DoPlayerWeather( s, 4, temp, currval );
}
else if( isSnowing && SnowThreshold( currval ) > Temp( currval ) )
{
DoPlayerWeather( s, 2, temp, currval );
if( p->GetWeathDamage( SNOW ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), SNOW )) )), SNOW );
if( p->GetWeathDamage( STORM ) != 0 )
p->SetWeathDamage( 0, STORM );
if( p->GetWeathDamage( RAIN ) != 0 )
p->SetWeathDamage( 0, RAIN );
SendJSWeather( p, STORM, temp );
}
else if( isRaining )
{
DoPlayerWeather( s, 1, temp, currval );
if( p->GetWeathDamage( RAIN ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), RAIN )) )), RAIN );
if( p->GetWeathDamage( SNOW ) != 0 )
p->SetWeathDamage( 0, SNOW );
if( p->GetWeathDamage( STORM ) != 0 )
p->SetWeathDamage( 0, STORM );
SendJSWeather( p, STORM, temp );
}
else
{
DoPlayerWeather( s, 0, temp, currval );
if( p->GetWeathDamage( SNOW ) != 0 )
p->SetWeathDamage( 0, SNOW );
if( p->GetWeathDamage( STORM ) != 0 )
p->SetWeathDamage( 0, STORM );
if( p->GetWeathDamage( RAIN ) != 0 )
p->SetWeathDamage( 0, RAIN );
SendJSWeather( p, STORM, temp );
}
if( (Races->Affect( p->GetRace(), HEAT )) && p->GetWeathDamage( HEAT ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), HEAT )) )), HEAT );
if( (Races->Affect( p->GetRace(), COLD )) && p->GetWeathDamage( COLD ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), COLD )) )), COLD );
return true;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool DoNPCStuff( CChar *p )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Updates weather effects for NPCs when light levels change,
//| or depending on whether NPC is inside or outside of buildings
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::DoNPCStuff( CChar *p )
{
if( !ValidateObject( p ) )
return true;
weathID currval = p->GetRegion()->GetWeather();
if( currval > weather.size() || weather.empty() || p->inBuilding() )
{
SendJSWeather( p, LIGHT, 0 );
return false;
}
bool isStorm = StormActive( currval );
bool isSnowing = SnowActive( currval );
bool isRaining = RainActive( currval );
SI08 temp = (SI08)Temp( currval );
if( isStorm )
{
SendJSWeather( p, STORM, temp );
if( p->GetWeathDamage( STORM ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), STORM )) )), STORM );
if( p->GetWeathDamage( SNOW ) != 0 )
p->SetWeathDamage( 0, SNOW );
if( p->GetWeathDamage( RAIN ) != 0 )
p->SetWeathDamage( 0, RAIN );
}
else if( isSnowing && SnowThreshold( currval ) > Temp( currval ) )
{
SendJSWeather( p, SNOW, temp );
if( p->GetWeathDamage( SNOW ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), SNOW )) )), SNOW );
if( p->GetWeathDamage( STORM ) != 0 )
p->SetWeathDamage( 0, STORM );
if( p->GetWeathDamage( RAIN ) != 0 )
p->SetWeathDamage( 0, RAIN );
}
else if( isRaining )
{
SendJSWeather( p, RAIN, temp );
if( p->GetWeathDamage( RAIN ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), RAIN )) )), RAIN );
if( p->GetWeathDamage( SNOW ) != 0 )
p->SetWeathDamage( 0, SNOW );
if( p->GetWeathDamage( STORM ) != 0 )
p->SetWeathDamage( 0, STORM );
}
else
{
SendJSWeather( p, LIGHT, temp );
if( p->GetWeathDamage( SNOW ) != 0 )
p->SetWeathDamage( 0, SNOW );
if( p->GetWeathDamage( STORM ) != 0 )
p->SetWeathDamage( 0, STORM );
if( p->GetWeathDamage( RAIN ) != 0 )
p->SetWeathDamage( 0, RAIN );
}
if( (Races->Affect( p->GetRace(), HEAT )) && p->GetWeathDamage( HEAT ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), HEAT )) )), HEAT );
if( (Races->Affect( p->GetRace(), COLD )) && p->GetWeathDamage( COLD ) == 0 )
p->SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( p->GetRace(), COLD )) )), COLD );
return true;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void SendJSWeather( CChar *mChar, WeatherType weathType, SI08 currentTemp )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sends weather changes to JS engine and triggers relevant JS events
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::SendJSWeather( CChar *mChar, WeatherType weathType, SI08 currentTemp )
{
// Check for events in specific scripts attached to character
std::vector<UI16> scriptTriggers = mChar->GetScriptTriggers();
for( auto scriptTrig : scriptTriggers )
{
cScript *toExecute = JSMapping->GetScript( scriptTrig );
if( toExecute != nullptr )
{
toExecute->OnWeatherChange( mChar, weathType );
toExecute->OnTempChange( mChar, currentTemp );
}
}
// Check global script as well
cScript *toExecuteGlobal = JSMapping->GetScript( static_cast<UI16>(0) );
if( toExecuteGlobal != nullptr )
{
toExecuteGlobal->OnWeatherChange( mChar, weathType );
toExecuteGlobal->OnTempChange( mChar, currentTemp );
}
}
//o-----------------------------------------------------------------------------------------------o
//| Function - void DoPlayerWeather( CSocket *s, UI08 weathType, SI08 currentTemp, weathID currval )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Sends weather effects to player's client
//o-----------------------------------------------------------------------------------------------o
void cWeatherAb::DoPlayerWeather( CSocket *s, UI08 weathType, SI08 currentTemp, weathID currval )
// Weather Types
// 0 - dry
// 1 - rain
// 2 - snow
// 3 - rain and snow
// 4 - storm is brewing
// 5 - storm
{
// Byte 1 - 0x65 (Weather)
// Byte 2 - Weather Type( 0, rain, 1, fierce storm, 2, snow, 3 a storm is brewing, and 0xFF none )
// Byte 3 - Particle count (upper limit of 70)
// Byte 4 - Temperature
if( s == nullptr )
return;
CPWeather dry( 0xFF, 0x00, currentTemp );
CPWeather rain( 0x00, (UI08)RainIntensity( currval ), currentTemp );
CPWeather storm( 0x01, (UI08)StormIntensity( currval ), currentTemp );
CPWeather snow( 0x02, (UI08)SnowIntensity( currval ), currentTemp );
CPWeather strmbrw( 0x03, (UI08)(StormIntensity( currval ) / 2), currentTemp );
CChar *mChar = s->CurrcharObj();
s->Send( &dry );
switch( weathType )
{
case 0: break;
case 1: s->Send( &rain ); break;
case 2:
Effects->PlaySound( mChar, 0x14 + RandomNum( 0, 1 ) );
s->Send( &snow );
break;
case 3:
s->Send( &rain );
Effects->PlaySound( mChar, 0x14 + RandomNum( 0, 1 ) );
s->Send( &snow );
break;
case 4:
Effects->PlaySound( mChar, 0x14 + RandomNum( 0, 1 ) );
s->Send( &strmbrw );
break;
case 5:
Effects->PlaySound( mChar, 0x14 + RandomNum( 0, 1 ) );
s->Send( &storm );
break;
default: break;
}
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 LightMin( weathID toCheck )
//| void LightMin( weathID toCheck, R32 newValue )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the light (min) value of specified weather system
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::LightMin( weathID toCheck )
{
return weather[toCheck].LightMin();
}
void cWeatherAb::LightMin( weathID toCheck, R32 newValue )
{
weather[toCheck].LightMin( newValue );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 LightMax( weathID toCheck )
//| void LightMax( weathID toCheck, R32 newValue )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the light (max) value of specified weather system
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::LightMax( weathID toCheck )
{
return weather[toCheck].LightMax();
}
void cWeatherAb::LightMax( weathID toCheck, R32 newValue )
{
weather[toCheck].LightMax( newValue );
}
//o-----------------------------------------------------------------------------------------------o
//| Function - R32 CurrentLight( weathID toCheck )
//| void CurrentLight( weathID toCheck, R32 newValue )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Gets/Sets the light (current) value of specified weather system
//o-----------------------------------------------------------------------------------------------o
R32 cWeatherAb::CurrentLight( weathID toCheck )
{
return weather[toCheck].CurrentLight();
}
void cWeatherAb::CurrentLight( weathID toCheck, R32 newValue )
{
weather[toCheck].CurrentLight( newValue );
}
CWeather *cWeatherAb::Weather( weathID toCheck )
{
if( toCheck >= weather.size() )
return nullptr;
else
return &weather[toCheck];
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool doLightEffect( CSocket *mSock, CChar& mChar )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Handles effects of light levels on characters affected by light
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::doLightEffect( CSocket *mSock, CChar& mChar )
{
bool didDamage = false;
if( mChar.IsInvulnerable() || mChar.IsDead() || !Races->Affect( mChar.GetRace(), LIGHT ) || mChar.inBuilding() )
return false;
if( mChar.GetWeathDamage( LIGHT ) != 0 && mChar.GetWeathDamage( LIGHT ) <= cwmWorldState->GetUICurrentTime() )
{
R32 damageModifier = 0;
SI32 damage = 0;
R32 baseDamage = (R32)Races->Damage( mChar.GetRace(), LIGHT );
R32 lightLevel = (R32)Races->LightLevel( mChar.GetRace() );
R32 currentLight = 255;
R32 lightMin = 255;
R32 lightMax = 255;
SI32 message = 0;
bool ampm = cwmWorldState->ServerData()->ServerTimeAMPM();
weathID weatherSys = mChar.GetRegion()->GetWeather();
if( !weather.empty() && weatherSys < weather.size() )
{
lightMin = LightMin( weatherSys );
lightMax = LightMax( weatherSys );
if( lightMin < 300 && lightMax < 300 )
currentLight = CurrentLight( weatherSys );
else
{
currentLight = cwmWorldState->ServerData()->WorldLightCurrentLevel();
lightMin = cwmWorldState->ServerData()->WorldLightDarkLevel();
lightMax = cwmWorldState->ServerData()->WorldLightBrightLevel();
}
}
else
{
currentLight = cwmWorldState->ServerData()->WorldLightCurrentLevel();
lightMin = cwmWorldState->ServerData()->WorldLightDarkLevel();
lightMax = cwmWorldState->ServerData()->WorldLightBrightLevel();
}
if ( mChar.inDungeon() )
{
R32 dungeonLight = 255;
dungeonLight = cwmWorldState->ServerData()->DungeonLightLevel();
if (lightLevel > dungeonLight )
{
if( lightLevel > 0)
damageModifier = ( dungeonLight / lightLevel );
else
damageModifier = 0;
damage = (SI32)roundNumber( baseDamage - ( baseDamage * damageModifier));
if( roundNumber( damageModifier ) > 0 )
message = 1216;
else
message = 1217;
}
else if( lightLevel == currentLight )
{
if( ampm )
message = 1218;
else
message = 1215;
}
}
else
{
if (lightLevel > currentLight )
{
if( lightLevel > 0)
damageModifier = ( currentLight / lightLevel );
else
damageModifier = 0;
damage = (SI32)roundNumber( baseDamage - ( baseDamage * damageModifier));
if( roundNumber( damageModifier ) > 0 )
message = 1216;
else
message = 1217;
}
else if( lightLevel == currentLight )
{
if( ampm )
message = 1218;
else
message = 1215;
}
}
damage = Combat->ApplyDefenseModifiers( LIGHT, nullptr, &mChar, 0, 0, damage, true);
if( damage > 0 )
{
mChar.Damage( damage, LIGHT );
Effects->PlayStaticAnimation( (&mChar), 0x3709, 0x09, 0x19 );
Effects->PlaySound( (&mChar), 0x0208 );
didDamage = true;
if( message != 0 && mSock != nullptr)
mSock->sysmessage( message );
}
mChar.SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( mChar.GetRace(), LIGHT )) )), LIGHT );
}
return didDamage;
}
//o-----------------------------------------------------------------------------------------------o
//| Function - bool doWeatherEffect( CSocket *mSock, CChar& mChar, WeatherType element )
//o-----------------------------------------------------------------------------------------------o
//| Purpose - Handles effects of weather on characters affected by weather
//o-----------------------------------------------------------------------------------------------o
bool cWeatherAb::doWeatherEffect( CSocket *mSock, CChar& mChar, WeatherType element )
{
WeatherType resistElement = element;
if( element == NONE || element == LIGHT || element == WEATHNUM )
return false;
if( mChar.IsInvulnerable() || mChar.IsDead() || !Races->Affect( mChar.GetRace(), element ) || mChar.inBuilding())
return false;
bool didDamage = false;
weathID weatherSys = mChar.GetRegion()->GetWeather();
if( !(weatherSys > weather.size() || weather.empty()) && mChar.GetWeathDamage( element ) != 0 && mChar.GetWeathDamage( element ) <= cwmWorldState->GetUICurrentTime())
{
const R32 tempCurrent = Temp( weatherSys );
//const R32 tempMax = MaxTemp( weatherSys );
//const R32 tempMin = MinTemp( weatherSys );
//const R32 tempSnowMax = SnowThreshold( weatherSys );
const R32 tempEffMax = EffectiveMaxTemp( weatherSys );
const R32 tempEffMin = EffectiveMinTemp( weatherSys );
R32 damageModifier = 0;
SI32 damage = 0;
R32 baseDamage = (R32)Races->Damage( mChar.GetRace(), element );
R32 heatLevel = (R32)Races->HeatLevel( mChar.GetRace() );
R32 coldLevel = (R32)Races->ColdLevel( mChar.GetRace() );
SI32 damageMessage = 0;
UI16 damageAnim = 0x373A;
if( element == RAIN )
{
damageModifier = (R32)RainIntensity( weatherSys );
damage = (SI32)roundNumber( ( baseDamage / 100 ) * damageModifier );
damageMessage = 1219;
resistElement = NONE;
}
if( element == SNOW )
{
damageModifier = (R32)SnowIntensity( weatherSys );
damage = (SI32)roundNumber( ( baseDamage / 100 ) * damageModifier );
damageMessage = 1220;
// Snow is also cold damage when it comes to resistance values
resistElement = COLD;
}
if( element == STORM)
{
damageModifier = (R32)StormIntensity( weatherSys );
damage = (SI32)roundNumber( ( baseDamage / 100 ) * damageModifier );
damageMessage = 1775;
resistElement = NONE;
if( Races->Affect( mChar.GetRace(), LIGHTNING ) )
{
if( (UI08)RandomNum( 0, 100 ) <= Races->Secs( mChar.GetRace(), LIGHTNING ) )
{
damage = (SI32)Races->Damage( mChar.GetRace(), LIGHTNING );
Effects->bolteffect( &mChar );
damageMessage = 1777;
damageAnim = 0x0;
resistElement = LIGHTNING;
}
}
}
if( element == COLD && tempCurrent <= coldLevel )
{
if( (coldLevel - tempEffMin) != 0)
damageModifier = ( (tempCurrent - tempEffMin) / (coldLevel - tempEffMin) );
else
damageModifier = 0;
damage = (SI32)roundNumber( baseDamage - ( baseDamage * damageModifier));
damageMessage = 1776;
}
if( element == HEAT && tempCurrent >= heatLevel)
{
if( (tempEffMax - heatLevel) != 0)
damageModifier = ( (tempCurrent - heatLevel) / (tempEffMax - heatLevel) );
else
damageModifier = 0;
damage = (SI32)roundNumber( baseDamage * damageModifier);
damageMessage = 1221;
damageAnim = 0x3709;
}
damage = Combat->ApplyDefenseModifiers( resistElement, nullptr, &mChar, 0, 0, damage, true);
if( damage > 0 )
{
mChar.Damage( damage, element );
mChar.SetStamina( mChar.GetStamina() - 2 );
if( mSock != nullptr )
mSock->sysmessage( damageMessage );
if( damageAnim != 0x0)
Effects->PlayStaticAnimation( (&mChar), damageAnim, 0x09, 0x19 );
Effects->PlaySound( (&mChar), 0x0208 );
didDamage = true;
}
mChar.SetWeathDamage( static_cast<UI32>(BuildTimeValue( static_cast<R32>(Races->Secs( mChar.GetRace(), element )) )), element );
}
return didDamage;
}