Beispiel #1
0
 def func(self):
     switches = [switch.lower() for switch in self.switches]
     character = self.character
     if self.cmdstring.lower() == 'ws':
         if not switches and not self.args:
             if not character:
                 self.msg("{RYou have no location.  (See {rhelp @char{R for more information)")
                 return
             if not character.location:
                 self.msg("{RYou don't seem to have any specific location.")
                 return
             self.display_users([ con for con in character.location.contents if utils.inherits_from(con, "src.objects.objects.Character") ])
             return
     else:
         if (not switches or switches == ['characters']) and not self.args:
             characters = set()
             for session in SESSIONS.get_sessions():
                 character = session.get_character()
                 if character:
                     character = character.typeclass
                     characters.add(character)
             self.display_users(characters)
             return
         if switches == ['players'] and not self.args:
             players = set()
             for session in SESSIONS.get_sessions():
                 player = session.get_player()
                 if player:
                     player = player.typeclass
                     players.add(player)
             self.display_users(players)
             return
         if switches == ['far'] and self.args:
             target = match(self.args)
             if not target:
                 self.msg('%cnNo match found for "' + self.args + "'")
                 return
             self.display_users([target])
             return
         if switches == ['room'] and not self.args:
             if not character:
                 self.msg("{RYou have no location.  (See {rhelp @char{R for more information)")
                 return
             if not character.location:
                 self.msg("{RYou don't seem to have any specific location.")
                 return
             self.display_users([ con for con in character.location.contents if utils.inherits_from(con, "src.objects.objects.Character") ])
             return
     self.msg("Invalid '%s' command.  See 'help %s' for usage" % (self.cmdstring, self.key))
Beispiel #2
0
 def func(self):
     player = self.player
     character = self.character
     # Check arguments
     message = self.args
     if not message:
         self.msg("{R[Invalid '{r%s{R' command.  See '{rhelp %s{R' for usage]" % (self.cmdstring, self.key))
         return
     # Format the message
     if character:
         # If we have a character, then we can use the 'say' routines to format the message.
         if message.startswith(':'):
             message = character.speech_pose(message[1:])
         elif message.startswith('"'):
             message = character.speech_say(message[1:])
         else:
             message = character.speech_say(message)
     else:
         # If we have no character, we'll have to take care of the formatting
         if message.startswith(':'):
             message = '{b' + player.key + '{n ' + message[1:].replace('{', '{{').replace('%', '%%')
         elif message.startswith('"'):
             message = '{b' + player.key + '{n: ' + message[1:].replace('{', '{{').replace('%', '%%')
         else:
             message = '{b' + player.key + '{n: ' + message.replace('{', '{{').replace('%', '%%')
     message = "{Y[ {cShout {Y| {n%s {Y]" % (message)
     # Send it
     for session in SESSIONS.get_sessions():
         session_sessid = session.sessid
         session_player = session.get_player()
         if not session_player:
             continue
         session_player.msg(message, sessid=session_sessid)
Beispiel #3
0
    def func(self):
        """
        Get all connected players by polling session.
        """

        player = self.player
        session_list = SESSIONS.get_sessions()

        session_list = sorted(session_list, key=lambda o: o.player.key)

        if self.cmdstring == "doing":
            show_session_data = False
        else:
            show_session_data = player.check_permstring(
                "Immortals") or player.check_permstring("Wizards")

        nplayers = (SESSIONS.player_count())
        if show_session_data:
            # privileged info
            table = prettytable.PrettyTable([
                "{wPlayer Name", "{wOn for", "{wIdle", "{wPuppeting", "{wRoom",
                "{wCmds", "{wProtocol", "{wHost"
            ])
            for session in session_list:
                if not session.logged_in: continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                puppet = session.get_puppet()
                location = puppet.location.key if puppet else "None"
                table.add_row([
                    utils.crop(player.name, width=25),
                    utils.time_format(delta_conn, 0),
                    utils.time_format(delta_cmd, 1),
                    utils.crop(puppet.key if puppet else "None", width=25),
                    utils.crop(location, width=25), session.cmd_total,
                    session.protocol_key,
                    isinstance(session.address, tuple) and session.address[0]
                    or session.address
                ])
        else:
            # unprivileged
            table = prettytable.PrettyTable(
                ["{wPlayer name", "{wOn for", "{wIdle"])
            for session in session_list:
                if not session.logged_in:
                    continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                table.add_row([
                    utils.crop(player.key, width=25),
                    utils.time_format(delta_conn, 0),
                    utils.time_format(delta_cmd, 1)
                ])

        isone = nplayers == 1
        string = "{wPlayers:{n\n%s\n%s unique account%s logged in." % (
            table, "One" if isone else nplayers, "" if isone else "s")
        self.msg(string)
Beispiel #4
0
    def func(self):
        """
        Contructs the desired loop based on switches.
        """
        construction = [ self.get_name, self.get_online_time, self.get_idle_time, self.get_status, self.get_location ]
        self.switches = [ switch.lower() for switch in self.switches ]
        if not getattr(self.caller, 'locks', None) or not \
            ('wiz' in self.switches and self.caller.locks.check_lockstring(self.caller, 'admin:perm(Immortals)')):
            self.admin = False # This is a session, not a player.
            construction.append(self.get_doing)
        else:
            construction.append(self.get_host)
            self.admin = True
        header = ''
        separator = ' '
        for function in construction:
             header += '%s%s{n' % (function.color, function.title)
             padding = function.spacing - len(function.title)
             header += separator * padding

        self.caller.msg(header)

        users = [ [session, ''] for session in SESSIONS.get_sessions() if check_ignores(self.caller, [session.get_character()], silent=True) ]

        if not self.admin:
            users = [ user for user in users if user[Who.SESSION].get_character() ]

        for user in users:
             for function in construction:
                 user[Who.STRING] += function.color + "%%-%ss" % function.spacing % function(user[Who.SESSION]) + '{n'
             self.caller.msg(user[Who.STRING])
Beispiel #5
0
    def get_all_connections(self, channel, online=False):
        """
        Return the connections of all players listening
        to this channel. If Online is true, it only returns
        connected players.
        """
        global _SESSIONS
        if not _SESSIONS:
            from src.server.sessionhandler import SESSIONS as _SESSIONS

        PlayerChannelConnection = ContentType.objects.get(app_label="comms",
                                                          model="playerchannelconnection").model_class()
        ExternalChannelConnection = ContentType.objects.get(app_label="comms",
                                                            model="externalchannelconnection").model_class()
        players = []
        if online:
            session_list = _SESSIONS.get_sessions()
            unique_online_users = set(sess.uid for sess in session_list if sess.logged_in)
            online_players = (sess.get_player() for sess in session_list if sess.uid in unique_online_users)
            for player in online_players:
                players.extend(PlayerChannelConnection.objects.filter(
                    db_player=player.dbobj, db_channel=channel.dbobj))
        else:
            players.extend(PlayerChannelConnection.objects.get_all_connections(channel))

        external_connections = ExternalChannelConnection.objects.get_all_connections(channel)

        return itertools.chain(players, external_connections)
Beispiel #6
0
    def func(self):
        """
        Get all connected players by polling session.
        """

        caller = self.caller
        session_list = SESSIONS.get_sessions()

        if self.cmdstring == "doing":
            show_session_data = False
        else:
            show_session_data = caller.check_permstring("Immortals") or caller.check_permstring("Wizards")

        if show_session_data:
            table = [["Player Name"], ["On for"], ["Idle"], ["Room"], ["Cmds"], ["Host"]]
        else:
            table = [["Player Name"], ["On for"], ["Idle"]]

        for session in session_list:
            if not session.logged_in:
                continue

            delta_cmd = time.time() - session.cmd_last_visible
            delta_conn = time.time() - session.conn_time
            plr_pobject = session.get_character()
            if not plr_pobject:
                plr_pobject = session.get_player()
                show_session_data = False
                table = [["Player Name"], ["On for"], ["Idle"]]
            if show_session_data:
                table[0].append(plr_pobject.name[:25])
                table[1].append(utils.time_format(delta_conn, 0))
                table[2].append(utils.time_format(delta_cmd, 1))
                table[3].append(plr_pobject.location and plr_pobject.location.id or "None")
                table[4].append(session.cmd_total)
                table[5].append(session.address[0])
            else:
                table[0].append(plr_pobject.name[:25])
                table[1].append(utils.time_format(delta_conn,0))
                table[2].append(utils.time_format(delta_cmd,1))

        stable = []
        for row in table: # prettify values
            stable.append([str(val).strip() for val in row])
        ftable = utils.format_table(stable, 5)
        string = ""
        for ir, row in enumerate(ftable):
            if ir == 0:
                string += "\n" + "{w%s{n" % ("".join(row))
            else:
                string += "\n" + "".join(row)
        nplayers = (SESSIONS.player_count())
        if nplayers == 1:
            string += '\nOne player logged in.'
        else:
            string += '\n%d players logged in.' % nplayers

        caller.msg(string)
Beispiel #7
0
    def func(self):
        """
        Get all connected players by polling session.
        """

        player = self.player
        session_list = SESSIONS.get_sessions()

        session_list = sorted(session_list, key=lambda o: o.player.key)

        if self.cmdstring == "doing":
            show_session_data = False
        else:
            show_session_data = player.check_permstring("Immortals") or player.check_permstring("Wizards")

        nplayers = (SESSIONS.player_count())
        if show_session_data:
            # privileged info
            table = prettytable.PrettyTable(["{wPlayer Name",
                                             "{wOn for",
                                             "{wIdle",
                                             "{wPuppeting",
                                             "{wRoom",
                                             "{wCmds",
                                             "{wProtocol",
                                             "{wHost"])
            for session in session_list:
                if not session.logged_in: continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                puppet = session.get_puppet()
                location = puppet.location.key if puppet else "None"
                table.add_row([utils.crop(player.name, width=25),
                               utils.time_format(delta_conn, 0),
                               utils.time_format(delta_cmd, 1),
                               utils.crop(puppet.key if puppet else "None", width=25),
                               utils.crop(location, width=25),
                               session.cmd_total,
                               session.protocol_key,
                               isinstance(session.address, tuple) and session.address[0] or session.address])
        else:
            # unprivileged
            table = prettytable.PrettyTable(["{wPlayer name", "{wOn for", "{wIdle"])
            for session in session_list:
                if not session.logged_in:
                    continue
                delta_cmd = time.time() - session.cmd_last_visible
                delta_conn = time.time() - session.conn_time
                player = session.get_player()
                table.add_row([utils.crop(player.key, width=25),
                               utils.time_format(delta_conn, 0),
                               utils.time_format(delta_cmd, 1)])

        isone = nplayers == 1
        string = "{wPlayers:{n\n%s\n%s unique account%s logged in." % (table, "One" if isone else nplayers, "" if isone else "s")
        self.msg(string)
Beispiel #8
0
 def func(self):
     if self.args and self.args.isdigit():
         self.show_whereare(int(self.args))
     elif not self.args and not self.switches:
         # Default threshold is 5% of the server's population
         characters = 0
         for session in SESSIONS.get_sessions():
             if session.get_character():
                 characters += 1
         self.show_whereare(characters / 20)
     else:
         self.msg("{R[Invalid '{r%s{R' command.  See '{rhelp %s{R' for usage]" % (self.cmdstring, self.key))
Beispiel #9
0
    def func(self):
        """
        Contructs the desired loop based on switches.
        """
        construction = [
            self.get_name, self.get_online_time, self.get_idle_time,
            self.get_status, self.get_location
        ]
        self.switches = [switch.lower() for switch in self.switches]
        if not getattr(self.caller, 'locks', None) or not \
            ('wiz' in self.switches and self.caller.locks.check_lockstring(self.caller, 'admin:perm(Immortals)')):
            self.admin = False  # This is a session, not a player.
            construction.append(self.get_doing)
        else:
            construction.append(self.get_host)
            self.admin = True
        header = ''
        separator = ' '
        for function in construction:
            header += '%s%s{n' % (function.color, function.title)
            padding = function.spacing - len(function.title)
            header += separator * padding

        self.caller.msg(header)

        users = [[session, ''] for session in SESSIONS.get_sessions()
                 if check_ignores(self.caller, [session.get_character()],
                                  silent=True)]

        if not self.admin:
            users = [
                user for user in users if user[Who.SESSION].get_character()
            ]

        for user in users:
            for function in construction:
                user[
                    Who.
                    STRING] += function.color + "%%-%ss" % function.spacing % function(
                        user[Who.SESSION]) + '{n'
            self.caller.msg(user[Who.STRING])
Beispiel #10
0
 def func(self):
     char_num = 0
     output = "{x________________{W_______________{w_______________{W_______________{x_________________\n"
     output += '%cnName         OnTime Idle  Name         OnTime Idle  Name         Ontime Idle\n'
     output += '\n'
     for session in SESSIONS.get_sessions():
         character = session.get_character()
         if not character:
             continue
         char_num += 1
         name = character.key
         onseconds = int(character.status_online())
         onminutes = onseconds / 60
         ontime = '%02d:%02d' % (onminutes / 60, onminutes % 60)
         idletime = self.tdelta_string(int(character.status_idle()))
         output += '%-12s %6s %-5s ' % (name[:12], ontime[:6], idletime[:5])
         if char_num and char_num % 3 == 0:
             output += '\n'
     if not output.endswith('\n'):
         output += '\n'
     output += "{x________________{W_______________{w_______________{W_______________{x_________________\n"
     self.msg(output.rstrip('\n'))
Beispiel #11
0
 def show_whereare(self, threshold):
     # Produce a list of locations
     locations = {}
     for session in SESSIONS.get_sessions():
         # Extract the location data
         character = session.get_character()
         if not character:
             continue
         character = character.typeclass
         location = character.location
         if not location or not hasattr(location, 'get_area'):
             continue
         area = location.get_area()
         if not area:
             continue
         region = area.get_region()
         if not region:
             continue
         # Add the location
         if not region in locations:
             locations[region] = {}
         if not area in locations[region]:
             locations[region][area] = {}
         if not location in locations[region][area]:
             locations[region][area][location] = set()
         locations[region][area][location].add(character)
     # Prune out locations that don't meet the threshold
     for region in locations.keys():
         for area in locations[region].keys():
             for location in locations[region][area].keys():
                 if len(locations[region][area][location]) < threshold:
                     del locations[region][area][location]
             if not locations[region][area]:
                 del locations[region][area]
         if not locations[region]:
             del locations[region]
     # Cache a list of friends
     my_friends = self.player.get_friend_characters(online_only=False)
     my_friends |= self.player.get_characters(online_only=False)
     # Output the results
     self.msg("{x________________{W_______________{w_______________{W_______________{x_________________")
     if not locations:
         self.msg('  {RNo rooms with %d or more characters.' % (threshold))
     else:
         for region in locations:
             self.msg(' {C' + string.capwords(region.objsub('&0w')) + '{C:')
             for area in locations[region]:
                 self.msg('   {C' + string.capwords(area.objsub('&0w')) + '{C:')
                 for location in locations[region][area]:
                     # Display the location
                     self.msg(evennia_color_left('     {c' + location.key + '{n'  + ('.' * 79), 73, dots=True) + evennia_color_right('{g' + str(len(locations[region][area][location])), 4, dots=True))
                     # Generate character lists
                     characters_here = set(char for char in location.contents if utils.inherits_from(char, "src.objects.objects.Character"))
                     friends_here = characters_here & my_friends
                     strangers_here = characters_here - friends_here
                     # Display character lists
                     charline = '       {x: Characters :{n '
                     if friends_here:
                         charline += '{n, '.join([friend.get_desc_styled_name(self.player) for friend in friends_here])
                         if strangers_here:
                             charline += '{n, plus '
                         else:
                             charline += '{n.'
                     if strangers_here:
                         charline += '{n%d awake and %d asleep.' % (len([stranger for stranger in strangers_here if stranger.sessid]), len([stranger for stranger in strangers_here if not stranger.sessid]))
                     self.msg(charline)
     self.msg("{x________________{W_______________{w_______________{W_______________{x_________________")
Beispiel #12
0
    def at_repeat(self):
        """
        This gets called every self.interval seconds.
        """
        
        msg = ""
        
        
        # Precipitation - Messages
        self.db.precipitation_msg_timer += self.interval
        
        if self.db.precipitation_level == 1 and self.db.precipitation_msg_timer >= 50:
            self.db.precipitation_msg_timer = 0
            if self.db.precipitation_type == "rain":
                msg = "Light rain is falling from the sky."
            elif self.db.precipitation_type == "snow":
                msg = "Small snowflakes are falling from the sky."
            elif self.db.precipitation_type == "hail":
                msg = "Small hailstones are falling from the sky."
        
        if self.db.precipitation_level == 2 and self.db.precipitation_msg_timer >= 30:
            self.db.precipitation_msg_timer = 0
            if self.db.precipitation_type == "rain":
                msg = "Rain is falling from the sky."
            elif self.db.precipitation_type == "snow":
                msg = "Snow is falling from the sky."
            elif self.db.precipitation_type == "hail":
                msg = "Hail is falling from the sky."
        
        if self.db.precipitation_level == 3 and self.db.precipitation_msg_timer >= 20:
            self.db.precipitation_msg_timer = 0
            if self.db.precipitation_type == "rain":
                msg = "Heavy rain is pouring down."
            elif self.db.precipitation_type == "snow":
                msg = "Large snowflakes are falling."
            elif self.db.precipitation_type == "hail":
                msg = "Large hailstones are hammering on the ground."
        
        if self.db.precipitation_level == 4 and self.db.precipitation_msg_timer >= 10:
            self.db.precipitation_msg_timer = 0
            if self.db.precipitation_type == "rain":
                msg = "Massive amounts of rain are pouring down."
            elif self.db.precipitation_type == "snow":
                msg = "Massive amounts of snow are falling."
            elif self.db.precipitation_type == "hail":
                msg = "Huge hailstones are crushing down from the skies."
        
        
        # Wind - Messages
        if self.db.wind_speed == 3 and random.random() < 0.005:
            messages = ["A fresh breeze is blowing.", "You feel the wind moving around you.", "There's a strong breeze in the air."]
            msg = messages[int(random.random() * len(messages))]
        
        if self.db.wind_speed == 4 and random.random() < 0.025: # Every 5 minutes on average
            messages = ["The wind whines around you.", "Strong winds swirl around you.", "Strong gusts of wind stirs the air.", "The wind whistles around you."]
            msg = messages[int(random.random() * len(messages))]

        if (self.db.wind_speed == 5 or self.db.wind_speed == 6) and random.random() < 0.2:
            messages = ["Storm winds are howling around you.", "A strong gust of wind almost throws you off-balance.", "Storm winds are hitting you hard.", "Storm winds are racing through the air."]
            msg = messages[int(random.random() * len(messages))]

        if self.db.wind_speed == 7 and random.random() < 0.3:
            messages = ["Hurricane winds are raging against you.", "Extreme winds are throwing things around.", "Terrible winds are creating havoc around you.", "Hurricane winds rip through the air.", "Hurricane winds roar around you."]
            msg = messages[int(random.random() * len(messages))]

        
        # Cloud density
        if random.random() < 0.025 * self.db.cloud_change_rate:
            # Only small chance of changing
            
            # Clear sky
            if self.db.cloud_density == 0:
                if random.random() < 0.5 * self.db.cloud_increase_rate:
                    self.db.cloud_density += 1
            
            # Few clouds
            elif self.db.cloud_density == 1:
                if random.random() < 0.5 * self.db.cloud_increase_rate:
                    self.db.cloud_density += 1
                    self.db.precipitation_increase_rate = 0.5
                else:
                    self.db.cloud_density -= 1
            
            # Light clouds
            elif self.db.cloud_density == 2:
                if random.random() < 0.5 * self.db.cloud_increase_rate:
                    self.db.cloud_density += 1
                    self.db.precipitation_increase_rate = 0.75
                else:
                    self.db.cloud_density -= 1
                    self.db.precipitation_increase_rate = 0
            
            # Partly cloudy
            elif self.db.cloud_density == 3:
                if random.random() < 0.3 * self.db.cloud_increase_rate:
                    self.db.cloud_density += 1
                    self.db.wind_increase_rate *= 1.5
                    self.db.precipitation_increase_rate = 1
                else:
                    self.db.cloud_density -= 1
                    self.db.precipitation_increase_rate = 0.5
            
            # Cloud covered
            elif self.db.cloud_density == 4:
                if random.random() < 0.2 * self.db.cloud_increase_rate:
                    self.db.cloud_density += 1
                    self.db.precipitation_increase_rate = 2
                    msg = "The clouds are darkening."
                else:
                    self.db.cloud_density -= 1
                    self.db.wind_increase_rate /= 1.5
                    self.db.precipitation_increase_rate = 0.75
            
            # Dark cloud covered
            elif self.db.cloud_density == 5:
                if random.random() < 0.3 * self.db.cloud_increase_rate:
                    self.db.cloud_density += 1
                    self.db.wind_increase_rate *= 1.5
                    self.db.precipitation_increase_rate = 2.5
                    msg = "The clouds are turning black. Everything is getting darker."
                else:
                    self.db.cloud_density -= 1
                    self.db.precipitation_increase_rate = 1
                    msg = "The clouds are lightening up."
            
            # Black clouds
            elif self.db.cloud_density == 6:
                if random.random() < 0.1 * self.db.cloud_increase_rate:
                    self.db.cloud_density += 1
                    self.db.wind_increase_rate *= 1.5
                    msg = "The clouds are turning into black, anvil-shaped monsters."
                else:
                    self.db.cloud_density -= 1
                    self.db.wind_increase_rate /= 1.5
                    self.db.precipitation_increase_rate = 2
                    msg = "The clouds are lightening up."
            
            # Black pillars
            elif self.db.cloud_density == 7:
                if random.random() < 0.4 * self.db.cloud_increase_rate:
                    pass
                else:
                    self.db.cloud_density -= 1
                    self.db.wind_increase_rate /= 1.5
                    msg = "The most threatening clouds are disappearing."
        
        
        
        # Wind speed
        if random.random() < 0.025 * self.db.wind_change_rate: # Every 5th minute
            # Only small chance of changing
            
            # Windless
            if self.db.wind_speed == 0:
                if random.random() < 0.75 * self.db.wind_increase_rate:
                    self.db.wind_speed += 1
            
            # Calm
            elif self.db.wind_speed == 1:
                if random.random() < 0.5 * self.db.wind_increase_rate:
                    self.db.wind_speed += 1
                else:
                    self.db.wind_speed -= 1
            
            # Gentle breeze
            elif self.db.wind_speed == 2:
                if random.random() < 0.35 * self.db.wind_increase_rate:
                    self.db.wind_speed += 1
                else:
                    self.db.wind_speed -= 1
            
            # Strong breeze
            elif self.db.wind_speed == 3:
                if random.random() < 0.25 * self.db.wind_increase_rate:
                    self.db.wind_speed += 1
                    #msg = "The wind is getting stronger."
                else:
                    self.db.wind_speed -= 1
            
            # Gale
            elif self.db.wind_speed == 4:
                if random.random() < 0.1 * self.db.wind_increase_rate:
                    self.db.wind_speed += 1
                    msg = "The wind has reached storm strength."
                else:
                    self.db.wind_speed -= 1
            
            # Storm
            elif self.db.wind_speed == 5:
                if random.random() < 0.1 * self.db.wind_increase_rate:
                    self.db.wind_speed += 1
                    msg = "The wind is extremely strong, surpassing a normal storm."
                else:
                    self.db.wind_speed -= 1
                    msg = "The wind is weakening. It's no longer a storm."
            
            # Violent storm
            elif self.db.wind_speed == 6:
                if random.random() < 0.05 * self.db.wind_increase_rate:
                    self.db.wind_speed += 1
                    #msg = "Hurricane winds are ripping through the air."
                else:
                    self.db.wind_speed -= 1
                    msg = "The wind is weakening, but remains strong."
            
            # Hurricane
            elif self.db.wind_speed == 7:
                if random.random() < 0.25 * self.db.wind_increase_rate:
                    pass
                else:
                    self.db.wind_speed -= 1
                    msg = "The wind is weakening, but remains very strong."
        
        
        
        # Precipitation
        if random.random() < 0.025 * self.db.precipitation_change_rate: # Every 5th minute            
            if self.db.precipitation_level == 0:
                if random.random() < (0.1 + self.db.wind_speed / 50) * self.db.precipitation_increase_rate:
                    self.db.precipitation_level += 1
            
            elif self.db.precipitation_level == 1:
                if random.random() < 0.2 * self.db.precipitation_increase_rate:
                    self.db.precipitation_level += 1
                elif random.random() < 0.4 * self.db.precipitation_increase_rate:
                    pass
                else:
                    self.db.precipitation_level -= 1
            
            elif self.db.precipitation_level == 2:
                if random.random() < 0.1 * self.db.precipitation_increase_rate:
                    self.db.precipitation_level += 1
                elif random.random() < 0.3 * self.db.precipitation_increase_rate:
                    pass
                else:
                    self.db.precipitation_level -= 1
            
            elif self.db.precipitation_level == 3:
                if random.random() < 0.05 * self.db.precipitation_increase_rate:
                    self.db.precipitation_level += 1
                elif random.random() < 0.15 * self.db.precipitation_increase_rate * self.db.precipitation_increase_rate:
                    pass
                else:
                    self.db.precipitation_level -= 1
            
            elif self.db.precipitation_level == 4:
                if random.random() < 0.15 * self.db.precipitation_increase_rate * self.db.precipitation_increase_rate:
                    pass
                else:
                    self.db.precipitation_level -= 1
            
            
            # Precipitation - Chance to change type
            if self.db.precipitation_type == "rain":
                if self.db.cloud_density >= 4 and self.db.wind_speed >= 4 and random.random() < 0.01:
                    self.db.precipitation_type == "hail"
                elif random.random() < 0.005:
                    self.db.precipitation_type == "snow"
            
            elif self.db.precipitation_type == "snow" and random.random() < 0.01:
                self.db.precipitation_type == "rain"
            
            elif self.db.precipitation_type == "hail" and random.random() < 0.1:
                self.db.precipitation_type == "rain"
            
                
        
        
        # TODO: Tornado. Thunder. Fog.
        #rooms = ev.search_tag("outdoors")

        
        if msg:
            # Send message to active players only.
            from src.server.sessionhandler import SESSIONS
            for s in SESSIONS.get_sessions():
                player_object = s.get_puppet()
                if s.logged_in and player_object and player_object.location.tags.get("outdoors"):
                    player_object.msg(msg)