View Full Version : weather
louis1016
03-31-2011, 06:45 PM
Hey, I seem to have a problem in my server with the weather effects changing. I have yet to ever see it change on its own, but using the #weather command works. I would like for the weather to change on its own though. What could be wrong?
ChaosSlayerZ
04-01-2011, 11:56 PM
default chance for weather to change is VERY tine - like 5%
similarly when it begins to rain - it will rain for hours, cause again, chance to swith back to good weather is also very small
however there is a perl script command now which allows you to run your own weather program (you can set your own random chance or switch it based of time of day etc), just need to disable weather options in zone table
louis1016
04-02-2011, 01:51 AM
That sounds perfect, but how do I find this? Sorry, im not experienced with perl scripts.
louis1016
04-02-2011, 02:04 AM
Alright so from searching on the forum it looks like I have to write a quest to do what you are saying. Can you please post a sample perl script for this? It would be awesome and id be very grateful.
trevius
04-02-2011, 05:55 AM
This should work, though I didn't actually test it:
File Name: player.pl - Save this in the zone folder you want to adjust weather for
sub EVENT_ENTERZONE {
# Set the type of weather desired here
my $weathertype = 1; # 0 for none, 1 for rain, 2 for snow
# Check if weather is not already set to the desired type
if ($zoneweather != $weathertype)
{
my $Rain = 1;
my $Snow = 2;
if ($weathertype == $Rain)
{
# Turn off snow (if it is on) and turn on rain
quest::snow(0);
quest::rain(1);
}
elsif ($weathertype == $Snow)
{
# Turn off rain (if it is on) and turn on snow
quest::rain(0);
quest::snow(1);
}
else
{
# Turn off both snow and rain
quest::rain(0);
quest::snow(0);
}
}
}
louis1016
04-02-2011, 02:30 PM
This is really awesome, thanks a lot!
louis1016
04-02-2011, 02:32 PM
Sorry - one last question, How can I modify this to be based on a chance percentage?
ChaosSlayerZ
04-02-2011, 02:53 PM
you need to insert a script that would generate sort of a random number and pull from its selection.
along these lines
my $a = quest::ChooseRandom(1, 2,3,4,5,6,7,8,9,10);
then you check with If statement which $a was choose, and set weather accordingly (like 1 to 5 - no weather, 6-8 rain, 9-10 snow)
louis1016
04-02-2011, 09:00 PM
OK, i took the time and learned a lot about how to use perl and I wrote this script I'd like to use that takes account a percentage chance of weather when you zone in and also after 1500 seconds it does it again. I know theres probably MUCH easier way to write it then what I did but here is what I came up with:
sub EVENT_ENTERZONE{
quest::settimer("weathertimer",1500);
my $randweather = int(rand(100));
if ($randweather <70) {
quest::rain(0);
quest::snow(0);
}
elsif ($randweather =71) {
quest::rain (1);
quest::snow(0);
}
elsif ($randweather =72){
quest::rain(2);
quest::snow(0);
}
elsif ($randweather =73){
quest::rain(3);
quest::snow(0);
}
elsif ($randweather =73){
quest::rain(3);
quest::snow(0);
}
elsif ($randweather =74){
quest::rain(4);
quest::snow(0);
}
elsif ($randweather =75){
quest::rain(5);
quest::snow(0);
}
elsif ($randweather =76){
quest::rain(6);
quest::snow(0);
}
elsif ($randweather =77){
quest::rain(7);
quest::snow(0);
}
elsif ($randweather =78){
quest::rain(8);
quest::snow(0);
}
elsif ($randweather =79){
quest::rain(9);
quest::snow(0);
}
elsif ($randweather =80){
quest::rain(10);
quest::snow(0);
}
elsif ($randweather =81){
quest::rain(11);
quest::snow(0);
}
elsif ($randweather =82){
quest::rain(12);
quest::snow(0);
}
elsif ($randweather =83){
quest::rain(13);
quest::snow(0);
}
elsif ($randweather =84){
quest::rain(14);
quest::snow(0);
}
elsif ($randweather =85){
quest::rain(15);
quest::snow(0);
}
elsif ($randweather =86){
quest::rain(16);
quest::snow(0);
}
elsif ($randweather =87){
quest::rain(17);
quest::snow(0);
}
elsif ($randweather =88){
quest::rain(18);
quest::snow(0);
}
elsif ($randweather =89){
quest::rain(19);
quest::snow(0);
}
elsif ($randweather =90){
quest::rain(20);
quest::snow(0);
}
elsif ($randweather =91){
quest::rain(0);
quest::snow(1);
}
elsif ($randweather =92){
quest::rain(0);
quest::snow(2);
}
elsif ($randweather =93){
quest::rain(0);
quest::snow(3);
}
elsif ($randweather =94){
quest::rain(0);
quest::snow(4);
}
elsif ($randweather =95){
quest::rain(0);
quest::snow(5);
}
elsif ($randweather =96){
quest::rain(0);
quest::snow(6);
}
elsif ($randweather =97){
quest::rain(0);
quest::snow(7);
}
elsif ($randweather =98){
quest::rain(0);
quest::snow(8);
}
elsif ($randweather =99){
quest::rain(0);
quest::snow(9);
}
elsif ($randweather =100){
quest::rain(0);
quest::snow(10);
}
sub EVENT_TIMER{
if ($timer eq "weathertimer")
{
quest::stoptimer("weathertimer");
my $secondrandweather = int(rand(100));
if ($secondrandweather <70) {
quest::rain(0);
quest::snow(0);
}
elsif ($secondrandweather =71) {
quest::rain (1);
quest::snow(0);
}
elsif ($secondrandweather =72){
quest::rain(2);
quest::snow(0);
}
elsif ($secondrandweather =73){
quest::rain(3);
quest::snow(0);
}
elsif ($secondrandweather =73){
quest::rain(3);
quest::snow(0);
}
elsif ($secondrandweather =74){
quest::rain(4);
quest::snow(0);
}
elsif ($secondrandweather =75){
quest::rain(5);
quest::snow(0);
}
elsif ($secondrandweather =76){
quest::rain(6);
quest::snow(0);
}
elsif ($secondrandweather =77){
quest::rain(7);
quest::snow(0);
}
elsif ($secondrandweather =78){
quest::rain(8);
quest::snow(0);
}
elsif ($secondrandweather =79){
quest::rain(9);
quest::snow(0);
}
elsif ($secondrandweather =80){
quest::rain(10);
quest::snow(0);
}
elsif ($secondrandweather =81){
quest::rain(11);
quest::snow(0);
}
elsif ($secondrandweather =82){
quest::rain(12);
quest::snow(0);
}
elsif ($secondrandweather =83){
quest::rain(13);
quest::snow(0);
}
elsif ($secondrandweather =84){
quest::rain(14);
quest::snow(0);
}
elsif ($secondrandweather =85){
quest::rain(15);
quest::snow(0);
}
elsif ($secondrandweather =86){
quest::rain(16);
quest::snow(0);
}
elsif ($secondrandweather =87){
quest::rain(17);
quest::snow(0);
}
elsif ($secondrandweather =88){
quest::rain(18);
quest::snow(0);
}
elsif ($secondrandweather =89){
quest::rain(19);
quest::snow(0);
}
elsif ($secondrandweather =90){
quest::rain(20);
quest::snow(0);
}
elsif ($secondrandweather =91){
quest::rain(0);
quest::snow(1);
}
elsif ($secondrandweather =92){
quest::rain(0);
quest::snow(2);
}
elsif ($secondrandweather =93){
quest::rain(0);
quest::snow(3);
}
elsif ($secondrandweather =94){
quest::rain(0);
quest::snow(4);
}
elsif ($secondrandweather =95){
quest::rain(0);
quest::snow(5);
}
elsif ($secondrandweather =96){
quest::rain(0);
quest::snow(6);
}
elsif ($secondrandweather =97){
quest::rain(0);
quest::snow(7);
}
elsif ($secondrandweather =98){
quest::rain(0);
quest::snow(8);
}
elsif ($secondrandweather =99){
quest::rain(0);
quest::snow(9);
}
elsif ($secondrandweather =100){
quest::rain(0);
quest::snow(10);
}
}
I feel as if this should work, is there anything wrong with this?
louis1016
04-02-2011, 09:20 PM
it doesnt work, can anyone help?
joligario
04-02-2011, 09:40 PM
Conditions use ==
Also, there may be too many elsif's. You won't know that until the script actually runs.
ChaosSlayerZ
04-03-2011, 12:22 AM
also, I am pretty sure there is no such thing as rain(15)
it either:
(1) - on
or
(0) - off
also, (0)'s should be in code be before (1)'s
louis1016
04-03-2011, 12:53 AM
Thanks for the help, im going to finish tweaking something. It appears that there were too many elsif's (i think)
but I have tested with numbers higher then 1 for the quest::rain(x) command and it does work and it seems to control the intensity of the weather. So far Ive seen much harder rainstorms/snowstorms at (10) rather than (1).
ChaosSlayerZ
04-03-2011, 01:44 AM
ah great to know- i thought that feature was lost to us =)
louis1016
04-03-2011, 01:46 AM
I have wrote a working random weather generator based on 3 levels of intensity based on the first code given to me above. I have tested it and it works and I'll post it here in case anyone else wants to use it. It has a chance of giving a low, medium, or high intensity rain/snowstorms. Change the values to whatever you see fit. Ignore the #comments.
sub EVENT_ENTERZONE {
# Set the type of weather desired here
my $weathertype = int(rand(15));
# Check if weather is not already set to the desired type
if ($zoneweather != $weathertype)
{
my $Rain = 1;
my $Snow = 2;
my $mrain = 3;
my $msnow = 4;
my $lrain = 5;
my $lsnow = 6;
if ($weathertype == $Rain)
{
# Turn off snow (if it is on) and turn on rain
quest::snow(0);
quest::rain(0);
quest::rain(20);
}
elsif ($weathertype == $Snow)
{
# Turn off rain (if it is on) and turn on snow
quest::rain(0);
quest::snow(0);
quest::snow(20);
}
elsif ($weathertype == $mrain)
{
quest::rain(0);
quest::snow(0);
quest::rain(10);
}
elsif ($weathertype == $msnow)
{
quest::rain(0);
quest::snow(0);
quest::snow(10);
}
elsif ($weathertype == $lrain)
{
quest::rain(0);
quest::snow(0);
quest::rain(1);
}
elsif ($weathertype == $lsnow)
{
quest::rain(0);
quest::snow(0);
quest::snow(1);
}
else
{
# Turn off both snow and rain
quest::rain(0);
quest::snow(0);
}
}
}
}
ChaosSlayerZ
04-03-2011, 12:30 PM
here is a curious question.
if it fires off player.pl, won't that mean that weather will change every time someone enters the zone?
So in 5 min, 5 people enter the zone, and weather changes 5 times =)
louis1016
04-04-2011, 02:06 AM
yes it is, i made that code just based on that first code someone posted, i run all dynamic zones so its fine for me but for something like static zones or a large population server something else must be done. A better method that I'm almost done writing is a player.pl script that changes to a random weather type with a random intensity after a random duration of being in the zone. That will work much better to seemlessly randomly change the weather in a zone. I dont know how the bigger servers handle their weather, but for small server purposes the player.pl scripts do the job just right.
ChaosSlayerZ
04-04-2011, 02:43 AM
you can attach a code to a invisible "teleport_man" npc, and run it on timer
then it won't be player dependent regardless number of players or static zones
louis1016
04-04-2011, 06:03 PM
thanks, ill try that
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.