Thread: perl script
View Single Post
  #1  
Old 04-06-2011, 01:26 PM
louis1016
Hill Giant
 
Join Date: Dec 2009
Posts: 157
Default perl script

Ok, heres a perl script I set up for weather for an invisible mob. Everything seems to run fine when I #repop the zone. The initial weather change can occur and the timer starts which repeats a random weather change. However, for some reason, whenever I first enter a zone (dynamic zones) and everything pops for the first time, it always starts raining. Since #repop works and reads the script correctly I cant understand what the problem is. Can anyone help? Heres the code:

Code:
sub EVENT_SPAWN {
	my $quickchange = int(rand(7));
	my $quickrain = 1;
	my $quicksnow = 2;
	if ($quickchange == $quickrain) {
		quest::rain(0);
		quest::snow(0);
		quest::rain("int(rand(80))"+1);
		quest::settimer("weatherchange",int(rand(3000))+100);
			 }
	elsif ($quickchange == $quicksnow) {
		quest::rain(0);
		quest::snow(0);
		quest::snow("int(rand(60))"+1);
		quest::settimer("weatherchange",int(rand(3000))+100); }
	else {
		quest::rain(0);
		quest::snow(0);
		quest::settimer("weatherchange",int(rand(3000))+100); 
}
}

sub EVENT_TIMER {
	if ($timer eq "weatherchange") {
		my $weather = int(rand(7));
		my $rain = 1;
		my $snow = 2;
		if ($weather == $rain){
			quest::rain(0);
			quest::snow(0);
			quest::rain("rand(int(80))"+1); }
		elsif ($weather == $snow) {
			quest::snow(0);
			quest::rain(0);
			quest::snow("rand(int(60))"+1); }
		else {
			quest::snow(0);
			quest::rain(0);
			}
		}
		}
Reply With Quote