Index: conf/commands.conf =================================================================== --- conf/commands.conf (revision 1602) +++ conf/commands.conf (working copy) @@ -43,3 +43,4 @@ commands_ini[29] = { ["name"] = "jail", ["path"] = "scripts/commands", ["parameters"] = "sis" }; commands_ini[30] = { ["name"] = "pardon", ["path"] = "scripts/commands", ["parameters"] = "s" }; commands_ini[31] = { ["name"] = "timeoffset", ["path"] = "scripts/commands", ["parameters"] = "i" }; +commands_ini[32] = { ["name"] = "setweather", ["path"] = "scripts/commands", ["parameters"] = "s" }; Index: scripts/commands/setweather.lua =================================================================== --- scripts/commands/setweather.lua (revision 0) +++ scripts/commands/setweather.lua (working copy) @@ -0,0 +1,57 @@ +----------------------------------------------------------- +-- [Command name]: setweather +-- [Author ]: +-- [Description ]: Changes weather of current zone +----------------------------------------------------------- + +----------------------------------------------------------- +-- Action +----------------------------------------------------------- + +function onTrigger(player,weather) +printf("Weather Change Requested"); + + if(weather=="NONE" or weather=="none" or weather=='0') then + player:setWeather(0); + elseif(weather=="SUNSHINE" or weather=="sunshine" or weather=='1') then + player:setWeather(1); + elseif(weather=="CLOUDS" or weather=="clouds" or weather=='2') then + player:setWeather(2); + elseif(weather=="FOG" or weather=="fog" or weather=='3') then + player:setWeather(3); + elseif(weather=="HOT SPELL" or weather=="hot spell" or weather=='4') then + player:setWeather(4); + elseif(weather=="HEAT WAVE" or weather=="heat wave" or weather=='5') then + player:setWeather(5); + elseif(weather=="RAIN" or weather=="rain" or weather=='6') then + player:setWeather(6); + elseif(weather=="SQUALL" or weather=="squall" or weather=='7') then + player:setWeather(7); + elseif(weather=="DUST STORM" or weather=="dust storm" or weather=='8') then + player:setWeather(8); + elseif(weather=="SAND STORM" or weather=="sand storm" or weather=='9') then + player:setWeather(9); + elseif(weather=="WIND" or weather=="wind" or weather=='10') then + player:setWeather(10); + elseif(weather=="GALES" or weather=="gales" or weather=='11') then + player:setWeather(11); + elseif(weather=="SNOW" or weather=="snow" or weather=='12') then + player:setWeather(12); + elseif(weather=="BLIZZARDS" or weather=="blizzards" or weather=='13') then + player:setWeather(13); + elseif(weather=="THUNDER" or weather=="thunder" or weather=='14') then + player:setWeather(14); + elseif(weather=="THUNDERSTORMS" or weather=="thunderstorm" or weather=='15') then + player:setWeather(15); + elseif(weather=="AURORAS" or weather=="auroras" or weather=='16') then + player:setWeather(16); + elseif(weather=="STELLAR GLARE" or weather=="stellar glare" or weather=='17') then + player:setWeather(17); + elseif(weather=="GLOOM" or weather=="gloom" or weather=='18') then + player:setWeather(18); + elseif(weather=="DARKNESS" or weather=="darkness" or weather=='19') then + player:setWeather(19); + else + print('Unrecognised Weather'); + end +end; \ No newline at end of file Index: sql/zone_weather.sql =================================================================== --- sql/zone_weather.sql (revision 0) +++ sql/zone_weather.sql (working copy) @@ -0,0 +1,186 @@ +-- phpMyAdmin SQL Dump +-- version 3.1.0-rc1 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Aug 10, 2012 at 11:18 AM +-- Server version: 5.0.51 +-- PHP Version: 5.2.6 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + +-- +-- Database: `dspdb` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `zone_weather` +-- + +DROP TABLE IF EXISTS `zone_weather`; +CREATE TABLE IF NOT EXISTS `zone_weather` ( + `zoneid` tinyint(3) unsigned NOT NULL default '0', + `default` tinyint(3) unsigned NOT NULL default '0', + `shared` tinyint(3) unsigned NOT NULL default '0', + `static` tinyint(3) unsigned NOT NULL default '0', + `none` tinyint(3) unsigned NOT NULL default '0', + `sunshine` tinyint(3) unsigned NOT NULL default '0', + `clouds` tinyint(3) unsigned NOT NULL default '0', + `fog` tinyint(3) unsigned NOT NULL default '0', + `hot_spell` tinyint(3) unsigned NOT NULL default '0', + `heat_wave` tinyint(3) unsigned NOT NULL default '0', + `rain` tinyint(3) unsigned NOT NULL default '0', + `squall` tinyint(3) unsigned NOT NULL default '0', + `dust_storm` tinyint(3) unsigned NOT NULL default '0', + `sand_storm` tinyint(3) unsigned NOT NULL default '0', + `wind` tinyint(3) unsigned NOT NULL default '0', + `gales` tinyint(3) unsigned NOT NULL default '0', + `snow` tinyint(3) unsigned NOT NULL default '0', + `blizzards` tinyint(3) unsigned NOT NULL default '0', + `thunder` tinyint(3) unsigned NOT NULL default '0', + `thunder_storms` tinyint(3) unsigned NOT NULL default '0', + `auroras` tinyint(3) unsigned NOT NULL default '0', + `stellar_glares` tinyint(3) unsigned NOT NULL default '0', + `gloom` tinyint(3) unsigned NOT NULL default '0', + `darkness` tinyint(3) unsigned NOT NULL default '0', + PRIMARY KEY (`zoneid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AVG_ROW_LENGTH=3; + +-- +-- Dumping data for table `zone_weather` +-- + +INSERT INTO `zone_weather` VALUES(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 10, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(25, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(26, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(29, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0); +INSERT INTO `zone_weather` VALUES(38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(46, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(57, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(58, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(59, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(61, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(62, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(73, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(74, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 20, 20, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(91, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(92, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(97, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(102, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(103, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(108, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(110, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(111, 2, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 40, 0, 0, 0, 0, 10, 2); +INSERT INTO `zone_weather` VALUES(112, 2, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, 0, 10, 0); +INSERT INTO `zone_weather` VALUES(113, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(114, 0, 0, 0, 0, 0, 0, 0, 10, 5, 0, 0, 60, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(117, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(119, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(121, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(122, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(123, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(124, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(125, 0, 0, 0, 0, 0, 0, 0, 10, 5, 0, 0, 60, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(126, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 20, 0, 0); +INSERT INTO `zone_weather` VALUES(128, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(136, 2, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 74, 40, 0, 0, 0, 0, 10, 2); +INSERT INTO `zone_weather` VALUES(137, 2, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, 0, 10, 0); +INSERT INTO `zone_weather` VALUES(138, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(147, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(149, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(150, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(151, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(153, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(154, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(155, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(156, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(157, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(158, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(159, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(160, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(161, 2, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 10, 0); +INSERT INTO `zone_weather` VALUES(162, 2, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(164, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(166, 0, 111, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(171, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(174, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(175, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(178, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 20, 0, 20, 0, 20, 0, 20, 0, 20, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(182, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 20); +INSERT INTO `zone_weather` VALUES(184, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(193, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(195, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(196, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(197, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(198, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(200, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(201, 11, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(202, 15, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(203, 13, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(204, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 20, 0); +INSERT INTO `zone_weather` VALUES(205, 0, 0, 0, 0, 0, 0, 0, 20, 20, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(207, 5, 0, 1, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(208, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(209, 9, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(211, 7, 0, 1, 0, 0, 0, 0, 0, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(212, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(213, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(220, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(221, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(227, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(228, 0, 0, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(247, 0, 0, 0, 0, 0, 0, 0, 20, 20, 0, 0, 20, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(248, 0, 103, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +INSERT INTO `zone_weather` VALUES(249, 0, 118, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); Index: src/map/lua/lua_baseentity.cpp =================================================================== --- src/map/lua/lua_baseentity.cpp (revision 1602) +++ src/map/lua/lua_baseentity.cpp (working copy) @@ -65,6 +65,7 @@ #include "../packets/shop_items.h" #include "../packets/shop_menu.h" #include "../packets/conquest_map.h" +#include "../packets/weather.h" #include "../battleutils.h" #include "../charutils.h" @@ -77,8 +78,8 @@ #include "../spell.h" #include "../trade_container.h" #include "../zoneutils.h" +#include "../weatherutils.h" - CLuaBaseEntity::CLuaBaseEntity(lua_State* L) { if( !lua_isnil(L,-1) ) @@ -624,6 +650,86 @@ return 1; } +/************************************************************************ +* * +* * +* * +************************************************************************/ +inline int32 CLuaBaseEntity::getWeather(lua_State *L) +{ + DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL); + + CCharEntity* PChar = (CCharEntity*)m_PBaseEntity; + CZone* PZone = zoneutils::GetZone(PChar->getZone()); + + WEATHER weather = PZone->GetWeather(); + + switch(weather) + { + case WEATHER_NONE: lua_pushinteger(L, 0); break; + case WEATHER_SUNSHINE: lua_pushinteger(L, 1); break; + case WEATHER_CLOUDS: lua_pushinteger(L, 2); break; + case WEATHER_FOG: lua_pushinteger(L, 3); break; + case WEATHER_HOT_SPELL: lua_pushinteger(L, 4); break; + case WEATHER_HEAT_WAVE: lua_pushinteger(L, 5); break; + case WEATHER_RAIN: lua_pushinteger(L, 6); break; + case WEATHER_SQUALL: lua_pushinteger(L, 7); break; + case WEATHER_DUST_STORM: lua_pushinteger(L, 8); break; + case WEATHER_SAND_STORM: lua_pushinteger(L, 9); break; + case WEATHER_WIND: lua_pushinteger(L, 10); break; + case WEATHER_GALES: lua_pushinteger(L, 11); break; + case WEATHER_SNOW: lua_pushinteger(L, 12); break; + case WEATHER_BLIZZARDS: lua_pushinteger(L, 13); break; + case WEATHER_THUNDER: lua_pushinteger(L, 14); break; + case WEATHER_THUNDERSTORMS: lua_pushinteger(L, 15); break; + case WEATHER_AURORAS: lua_pushinteger(L, 16); break; + case WEATHER_STELLAR_GLARE: lua_pushinteger(L, 17); break; + case WEATHER_GLOOM: lua_pushinteger(L, 18); break; + case WEATHER_DARKNESS: lua_pushinteger(L, 19); break; + default: lua_pushnil(L); + } + return 1; +} + +inline int32 CLuaBaseEntity::setWeather(lua_State *L) +{ + DSP_DEBUG_BREAK_IF(m_PBaseEntity == NULL); + DSP_DEBUG_BREAK_IF(lua_isnil(L,1) || !lua_isnumber(L,1)); + + CCharEntity* PChar = (CCharEntity*)m_PBaseEntity; + CZone* PZone = zoneutils::GetZone(PChar->getZone()); + WEATHER weather; + + switch((uint16)lua_tointeger(L,1)) + { + case 0: weather = WEATHER_NONE; break; + case 1: weather = WEATHER_SUNSHINE; break; + case 2: weather = WEATHER_CLOUDS; break; + case 3: weather = WEATHER_FOG; break; + case 4: weather = WEATHER_HOT_SPELL; break; + case 5: weather = WEATHER_HEAT_WAVE; break; + case 6: weather = WEATHER_RAIN; break; + case 7: weather = WEATHER_SQUALL; break; + case 8: weather = WEATHER_DUST_STORM; break; + case 9: weather = WEATHER_SAND_STORM; break; + case 10: weather = WEATHER_WIND; break; + case 11: weather = WEATHER_GALES; break; + case 12: weather = WEATHER_SNOW; break; + case 13: weather = WEATHER_BLIZZARDS; break; + case 14: weather = WEATHER_THUNDER; break; + case 15: weather = WEATHER_THUNDERSTORMS; break; + case 16: weather = WEATHER_AURORAS; break; + case 17: weather = WEATHER_STELLAR_GLARE; break; + case 18: weather = WEATHER_GLOOM; break; + case 19: weather = WEATHER_DARKNESS; break; + default: weather = WEATHER_NONE; + } + + weatherutils::ImplementWeather(PZone, weather); + + return 0; +} + //==========================================================// inline int32 CLuaBaseEntity::getNation(lua_State *L) @@ -4295,6 +4402,8 @@ LUNAR_DECLARE_METHOD(CLuaBaseEntity,getZone), LUNAR_DECLARE_METHOD(CLuaBaseEntity,getPreviousZone), LUNAR_DECLARE_METHOD(CLuaBaseEntity,isZoneVisited), + LUNAR_DECLARE_METHOD(CLuaBaseEntity,getWeather), + LUNAR_DECLARE_METHOD(CLuaBaseEntity,setWeather), LUNAR_DECLARE_METHOD(CLuaBaseEntity,setPos), LUNAR_DECLARE_METHOD(CLuaBaseEntity,getRace), LUNAR_DECLARE_METHOD(CLuaBaseEntity,getNation), Index: src/map/lua/lua_baseentity.h =================================================================== --- src/map/lua/lua_baseentity.h (revision 1602) +++ src/map/lua/lua_baseentity.h (working copy) @@ -78,9 +78,11 @@ int32 getYPos(lua_State*); // Get Entity Y position int32 getZPos(lua_State*); // Get Entity Z position int32 setPos(lua_State*); // Set Entity position (zone,x,y,z) - int32 getZone(lua_State*); // Get Entity zone + int32 getZone(lua_State*); // Get Entity zone int32 getPreviousZone(lua_State*); // Get Entity previous zone int32 isZoneVisited(lua_State*); // true если указанная зона посещалась персонажем ранее + int32 getWeather(lua_State*); // Get Weather condition + int32 setWeather(lua_State*); // Set Weather condition (GM COMMAND) int32 takeMagicDamage(lua_State*); // Index: src/map/map.cpp =================================================================== --- src/map/map.cpp (revision 1602) +++ src/map/map.cpp (working copy) @@ -49,6 +49,7 @@ #include "transport.h" #include "vana_time.h" #include "zoneutils.h" +#include "weatherutils.h" #include "ai/ai_char_gm.h" #include "ai/ai_char_normal.h" @@ -201,6 +202,8 @@ CREATE(PTempBuff, int8, map_config.buffer_size + 20); ShowStatus("The map-server is " CL_GREEN"ready" CL_RESET" to work...\n"); ShowMessage("=======================================================================\n"); + + weatherutils::UpdateZoneWeather(); return 0; } Index: src/map/time_server.cpp =================================================================== --- src/map/time_server.cpp (revision 1602) +++ src/map/time_server.cpp (working copy) @@ -28,12 +28,18 @@ #include "transport.h" #include "vana_time.h" #include "zoneutils.h" +#include "weatherutils.h" int32 time_server(uint32 tick,CTaskMgr::CTask* PTask) { TIMETYPE VanadielTOTD = CVanaTime::getInstance()->SyncTime(); + if (CVanaTime::getInstance()->getHour() % 4 == 0 && CVanaTime::getInstance()->getMinute() == 30) + { + weatherutils::UpdateZoneWeather(); + } + if (VanadielTOTD != TIME_NONE) { zoneutils::TOTDCharnge(VanadielTOTD); Index: src/map/weatherutils.cpp =================================================================== --- src/map/weatherutils.cpp (revision 0) +++ src/map/weatherutils.cpp (working copy) @@ -0,0 +1,224 @@ +/* +=========================================================================== + + Copyright (c) 2010-2012 Darkstar Dev Teams + + This program 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 3 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, see http://www.gnu.org/licenses/ + + This file is part of DarkStar-server source code. + +=========================================================================== +*/ + +#include "../common/timer.h" + +#include "packets/weather.h" + +#include "zoneutils.h" +#include "charutils.h" +#include "weatherutils.h" +#include "mobutils.h" +//#include "battleutils.h" + +namespace weatherutils +{ +/************************************************************************ +* * +* determines what weather conditions each zone qualifies for * +* and what the current weather condition should be * +* * +************************************************************************/ +void UpdateZoneWeather() +{ + CZone* currentZone; + const int8* fmtQuery; + int32 ret; + int32 weatherFrequency = 0; + int32 weatherChange = 0; + WEATHER weatherType = WEATHER_NONE; + WEATHER weatherTypes [20] = {WEATHER_NONE, + WEATHER_SUNSHINE, + WEATHER_CLOUDS, + WEATHER_FOG, + WEATHER_HOT_SPELL, + WEATHER_HEAT_WAVE, + WEATHER_RAIN, + WEATHER_SQUALL, + WEATHER_DUST_STORM, + WEATHER_SAND_STORM, + WEATHER_WIND, + WEATHER_GALES, + WEATHER_SNOW, + WEATHER_BLIZZARDS, + WEATHER_THUNDER, + WEATHER_THUNDERSTORMS, + WEATHER_AURORAS, + WEATHER_STELLAR_GLARE, + WEATHER_GLOOM, + WEATHER_DARKNESS}; + + //lookup possible weather for each zone + for(int32 zoneid = 0; zoneid < 256; zoneid++) + { + weatherType = WEATHER_NONE; + currentZone = zoneutils::GetZone(zoneid); + + fmtQuery = "SELECT weather.none,weather.sunshine,weather.clouds,weather.fog,weather.hot_spell, \ + weather.heat_wave,weather.rain,weather.squall,weather.dust_storm,weather.sand_storm, \ + weather.wind,weather.gales,weather.snow,weather.blizzards,weather.thunder, \ + weather.thunder_storms,weather.auroras,weather.stellar_glares,weather.gloom,weather.darkness, \ + weather.shared, weather.static \ + FROM zone_weather AS weather \ + WHERE zoneid = %u LIMIT 1"; + + ret = Sql_Query(SqlHandle, fmtQuery, currentZone->GetID()); + + if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0 && Sql_NextRow(SqlHandle) == SQL_SUCCESS) + { + //skip zones with static weather + if ((uint8)Sql_GetIntData(SqlHandle,21) == 0) + { + //set weather for shared zones + if((uint8)Sql_GetIntData(SqlHandle,20) != 0) + { + weatherType = zoneutils::GetZone((uint8)Sql_GetIntData(SqlHandle,20))->GetWeather(); + } + else + { + //cycle through all weathers + for(int32 w = 1; w < 19; w++) + { + //generate a new random chance for each weather condidtion + weatherChange = rand()%100+1; + weatherFrequency = (int32)Sql_GetIntData(SqlHandle,w); + + if(weatherFrequency >= weatherChange) + { + weatherType = weatherTypes[w]; + } + } + //call ImplementWeather to update players and spawn/despawn mobs + } + ImplementWeather(currentZone, weatherType); + } + } + } + ShowDebug(CL_CYAN"UpdateWeather Finished\n"CL_RESET); +} +/************************************************************************ +* * +* if required, updates the weather for each player in the zone * +* and spawns/despawns the elemental mobs based on the weather * +* * +************************************************************************/ +void ImplementWeather(CZone* currentZone, WEATHER weatherType) +{ + //exit if weatherType matches current weather + if (currentZone->GetWeather() == weatherType) + return; + + CMobEntity* PMob; + const int8* elementalName = "None"; + + EntityList_t charList = currentZone->GetPCs(); + currentZone->SetWeather(weatherType); + + //update each player in the zone with the current weather + for (EntityList_t::const_iterator it = charList.begin() ; it != charList.end() ; ++it) + { + CCharEntity* PCurrentChar = (CCharEntity*)it->second; + PCurrentChar->pushPacket(new CWeatherPacket(1, weatherType)); + } + + //lookup all elemental mobs for the current zone + const int8* fmtQuery = "SELECT mobs.mobid \ + FROM mob_spawn_points AS mobs \ + INNER JOIN mob_groups AS groups USING (groupid) \ + WHERE mobs.pos_x != 0 AND mobs.pos_y != 0 AND mobs.pos_z != 0 \ + AND mobs.pos_x != 0 AND mobs.pos_y != 0 AND mobs.pos_z != 0 \ + AND groups.spawntype = 4 AND groups.zoneid = %u AND mobs.mobname LIKE '%%_Elemental'"; + + int32 ret = Sql_Query(SqlHandle, fmtQuery, currentZone->GetID()); + + //determine which elementals should spawn + if (ret != SQL_ERROR && Sql_NumRows(SqlHandle) != 0) + { + switch(weatherType) + { + case WEATHER_HOT_SPELL: + case WEATHER_HEAT_WAVE: + elementalName = "Fire_Elemental"; + break; + case WEATHER_RAIN: + case WEATHER_SQUALL: + elementalName = "Water_Elemental"; + break; + case WEATHER_DUST_STORM: + case WEATHER_SAND_STORM: + elementalName = "Earth_Elemental"; + break; + case WEATHER_WIND: + case WEATHER_GALES: + elementalName = "Air_Elemental"; + break; + case WEATHER_SNOW: + case WEATHER_BLIZZARDS: + elementalName = "Ice_Elemental"; + break; + case WEATHER_THUNDER: + case WEATHER_THUNDERSTORMS: + elementalName = "Thunder_Elemental"; + break; + case WEATHER_AURORAS: + case WEATHER_STELLAR_GLARE: + elementalName = "Light_Elemental"; + break; + case WEATHER_GLOOM: + case WEATHER_DARKNESS: + elementalName = "Dark_Elemental"; + break; + } + + while(Sql_NextRow(SqlHandle) == SQL_SUCCESS) + { + PMob = (CMobEntity*)zoneutils::GetEntity((int32)Sql_GetIntData(SqlHandle,0), TYPE_MOB); + + if (PMob != NULL) + { + //despawn incorrect elemental type + if ( strcmp(PMob->GetName(), elementalName) != 0 ) + { + if(PMob->m_OwnerID.id != 0) + { + PMob->SetDespawnTimer(1); + } + else + { + PMob->PBattleAI->SetLastActionTime(gettick() - 1200000); + PMob->m_SpawnType = (SPAWNTYPE)4; + PMob->PBattleAI->SetCurrentAction(ACTION_DEATH); + } + } + //spawn corrent element type + else + { + PMob->SetDespawnTimer(0); + PMob->m_SpawnType = (SPAWNTYPE)0; + PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN); + } + } + } + } +} +}; //end namespace \ No newline at end of file Index: src/map/weatherutils.h =================================================================== --- src/map/weatherutils.h (revision 0) +++ src/map/weatherutils.h (working copy) @@ -0,0 +1,35 @@ +/* +=========================================================================== + + Copyright (c) 2010-2012 Darkstar Dev Teams + + This program 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 3 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, see http://www.gnu.org/licenses/ + + This file is part of DarkStar-server source code. + +=========================================================================== +*/ + +#ifndef _WEATHERUTILS_H +#define _WEATHERUTILS_H + +#include "../common/cbasetypes.h" + +namespace weatherutils +{ + void UpdateZoneWeather(); + void ImplementWeather(CZone* currentZone, WEATHER weatherType); +}; + +#endif \ No newline at end of file Index: src/map/zone.cpp =================================================================== --- src/map/zone.cpp (revision 1602) +++ src/map/zone.cpp (working copy) @@ -106,6 +106,7 @@ m_TreasurePool = 0; m_RegionCheckTime = 0; m_InstanceHandler = NULL; + m_weather = WEATHER_NONE; switch(m_zoneID){ //all bcnm zones case 6: @@ -218,12 +219,26 @@ { return m_tax; } +WEATHER CZone::GetWeather() +{ + return m_weather; +} +void CZone::SetWeather(WEATHER weatherCondition) +{ + m_weather = weatherCondition; +} + const int8* CZone::GetName() { return m_zoneName.c_str(); } +EntityList_t CZone::GetPCs() +{ + return m_charList; +} + uint8 CZone::GetSoloBattleMusic() { return m_zoneMusic.m_bSongS; @@ -297,8 +312,10 @@ void CZone::LoadZoneSettings() { - const int8* fmtQuery = "SELECT name, zoneip, zoneport, music, battlesolo, battlemulti, tax, misc \ - FROM zone_settings \ + const int8* fmtQuery = "SELECT settings.name, settings.zoneip, settings.zoneport, settings.music, \ + settings.battlesolo, settings.battlemulti, settings.tax, settings.misc, weather.default \ + FROM zone_settings AS settings \ + LEFT JOIN zone_weather AS weather USING (zoneid) \ WHERE zoneid = %u \ LIMIT 1"; @@ -308,7 +325,7 @@ Sql_NumRows(SqlHandle) == 0 || Sql_NextRow(SqlHandle) != SQL_SUCCESS) { - ShowFatalError(CL_RED"CZone::LoadZoneSettings: Cannot loading zone settings (%u)\n" CL_RESET, m_zoneID); + ShowFatalError(CL_RED"CZone::LoadZoneSettings: Cannot load zone settings (%u)\n" CL_RESET, m_zoneID); } else { @@ -324,6 +341,34 @@ m_tax = (uint16)(Sql_GetFloatData(SqlHandle,6) * 100); // tax for bazaar m_miscMask = (uint16)Sql_GetUIntData(SqlHandle,7); + if(Sql_GetUIntData(SqlHandle,8) != NULL) + { + WEATHER weatherTypes [20] = + { + WEATHER_NONE, + WEATHER_SUNSHINE, + WEATHER_CLOUDS, + WEATHER_FOG, + WEATHER_HOT_SPELL, + WEATHER_HEAT_WAVE, + WEATHER_RAIN, + WEATHER_SQUALL, + WEATHER_DUST_STORM, + WEATHER_SAND_STORM, + WEATHER_WIND, + WEATHER_GALES, + WEATHER_SNOW, + WEATHER_BLIZZARDS, + WEATHER_THUNDER, + WEATHER_THUNDERSTORMS, + WEATHER_AURORAS, + WEATHER_STELLAR_GLARE, + WEATHER_GLOOM, + WEATHER_DARKNESS + }; + m_weather = weatherTypes[(uint8)Sql_GetUIntData(SqlHandle,8)]; + } + if (m_miscMask & MISC_TREASURE) { m_TreasurePool = new CTreasurePool(TREASUREPOOL_ZONE); @@ -733,7 +778,7 @@ { PChar->PTreasurePool = new CTreasurePool(TREASUREPOOL_SOLO); PChar->PTreasurePool->AddMember(PChar); - } + } } /************************************************************************ @@ -987,6 +1032,9 @@ CCharEntity* PCurrentChar = (CCharEntity*)it->second; SpawnIDList_t::iterator PC = PChar->SpawnPCList.find(PCurrentChar->id); + WEATHER currentWeather = GetWeather(); + PCurrentChar->pushPacket(new CWeatherPacket(0, currentWeather)); + if (PChar != PCurrentChar) { if(distance(PChar->loc.p, PCurrentChar->loc.p) < 50) Index: src/map/zone.h =================================================================== --- src/map/zone.h (revision 1602) +++ src/map/zone.h (working copy) @@ -34,6 +34,7 @@ #include "region.h" #include "vana_time.h" #include "instance_handler.h" +#include "packets\weather.h" enum ZONEMISC { @@ -107,7 +108,10 @@ uint32 GetIP(); uint16 GetPort(); uint16 GetTax(); + WEATHER GetWeather(); + void SetWeather(WEATHER weatherCondition); const int8* GetName(); + EntityList_t GetPCs(); uint8 GetSoloBattleMusic(); uint8 GetPartyBattleMusic(); uint8 GetBackgroundMusic(); @@ -161,6 +165,7 @@ string_t m_zoneName; // имя зоны uint16 m_zonePort; // порт зоны uint32 m_zoneIP; // IP зоны + WEATHER m_weather; uint16 m_tax; // налог в bazaar uint16 m_miscMask; // битовое поле, описывающее возможности использования в зоне определенных умений Index: win32/DSGame-server/DSGame-server.vcxproj =================================================================== --- win32/DSGame-server/DSGame-server.vcxproj (revision 1602) +++ win32/DSGame-server/DSGame-server.vcxproj (working copy) @@ -272,6 +272,7 @@ + @@ -447,6 +448,7 @@ + @@ -458,4 +460,4 @@ - + \ No newline at end of file Index: win32/DSGame-server/DSGame-server.vcxproj.filters =================================================================== --- win32/DSGame-server/DSGame-server.vcxproj.filters (revision 1602) +++ win32/DSGame-server/DSGame-server.vcxproj.filters (working copy) @@ -590,6 +590,12 @@ Header Files\lua + + Header Files + + + Header Files + @@ -1105,6 +1111,12 @@ Source Files\lua + + Source Files + + + Source Files +