/**
* 'Proof-of-concept' of dynamic weather changing.
*
* Home post:
* https://goldsrc.ru/threads/2789/page-2#post-46643
*
* Video:
* https://www.youtube.com/watch?v=QMkdrM2uww8
*
* Last update:
* 1/13/2016
*/
/* Copyright 2016 Safety1st
'Dynamic Weather' is free software;
you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <amxmodx>
#define PLUGIN "Dynamic Weather"
#define VERSION "0.3"
#define AUTHOR "Safety1st"
/*----------------------EDIT ME-------------------------*/
const FOG_COLOR = 0xE6E6F0 // RGB: 230 230 240 in hex
#define FOG_DENSITY_FULL 0.0020 // range from 0 to 0.01
#define FOG_DENSITY_HALF 0.0010
#define FOG_DENSITY_LOW 0.0005
/*------------------------------------------------------*/
new gMsgReceiveW, gMsgFog
new giWeatherType
enum _:WeatherMax {
WEATHER_NONE,
WEATHER_FOG,
WEATHER_RAIN,
WEATHER_RAINFOG,
WEATHER_SNOW,
WEATHER_SNOWFOG
}
const SHOW_NONE = 0
const SHOW_RAIN = 1
const SHOW_SNOW = 2
const FOG_DENSITY_0 = 0
new gszWeatherType[WeatherMax][] = {
"no weather",
"weather fog",
"weather rain",
"weather rain + fog",
"weather snow",
"weather snow + fog"
}
public plugin_init() {
register_plugin( PLUGIN, VERSION, AUTHOR )
gMsgReceiveW = get_user_msgid( "ReceiveW" )
gMsgFog = get_user_msgid( "Fog" )
register_clcmd( "changeweather", "ClCmd" )
}
public ClCmd(id) {
ChangeWeather(id)
return PLUGIN_HANDLED
}
ChangeWeather(id) {
if( ++giWeatherType == WeatherMax )
giWeatherType = WEATHER_NONE
message_begin( MSG_ONE_UNRELIABLE , gMsgReceiveW, .player = id )
switch( giWeatherType ) {
case WEATHER_RAIN, WEATHER_RAINFOG : write_byte( SHOW_RAIN )
case WEATHER_SNOW, WEATHER_SNOWFOG : write_byte( SHOW_SNOW )
default : write_byte( SHOW_NONE )
}
message_end()
message_begin( MSG_ONE_UNRELIABLE , gMsgFog, .player = id )
write_byte( FOG_COLOR >> 16 )
write_byte( FOG_COLOR >> 8 )
write_byte( FOG_COLOR )
switch( giWeatherType ) {
case WEATHER_FOG : write_long( _:FOG_DENSITY_FULL )
case WEATHER_RAINFOG :write_long( _:FOG_DENSITY_LOW )
case WEATHER_SNOWFOG : write_long( _:FOG_DENSITY_HALF )
default : write_long( FOG_DENSITY_0 )
}
message_end()
client_print( id, print_chat, gszWeatherType[giWeatherType] )
}