[CSGO/ANY] Weather/Time Plugin.

A place for requesting new Source.Python plugins to be made for your server.

Please request only one plugin per thread.
User avatar
Grubbsy
Junior Member
Posts: 12
Joined: Sat Aug 29, 2020 10:12 pm

[CSGO/ANY] Weather/Time Plugin.

Postby Grubbsy » Mon Nov 23, 2020 11:53 pm

I want a plugin to be able to change the weather of a map.

I have no reference videos or images to post other than wanting to be able to reload the map and have a func_priciptation/whatever causes rain
I also want to be able to edit the light_environment/ light levels on it (Not sure if light_environment editing works)

I basically want to be able to edit any map to fit this aesthetic https://youtu.be/MzJjzEEphfM

I've always wanted to have an easy access weather plugin that worked well.

Itemized list:
- Be able to add rain/any weather effect in csgo/hl2dm should work with the ash being an additional effect.
- Being able to change skybox
- Being able to change the map's lighting/ light style
- Bonus points for Fog.

Here are a few starting things to test
sky_csgo_cloudy01
Example Map Ideal Sun Angle Ideal Sun Pitch Ideal Brightness Ideal Ambience
http://prntscr.com/vor6tt


I've been a mapper for CSGO For a long time so it would be understandable if editing the lighting isn't really possible, I've seen it done before but sadly this was before I knew their tricks. I have since lost contact with them.
From what I remember of their tricks they had parented a light to a prop. I think a light_dynamic or something else that would allow for changing of the lights.

I would greatly appreciate those who attempt this!
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO/ANY] Weather/Time Plugin.

Postby VinciT » Tue Nov 24, 2020 5:46 am

Dang, this is a biggie. Lots of interesting problems to solve, and plenty of ways to do it.
As I'm currently working on a few of my own plugins (cough "few days" cough) with what free time I have, I can't fulfill your request. But I can leave a few bits and pieces in case anyone else (or even yourself) wants to tackle this.

With this snippet, you can change the skybox (with a few caveats):

Syntax: Select all

# ../change_skybox/change_skybox.py

# Source.Python
from commands.server import ServerCommand
from entities.helpers import index_from_edict
from listeners import OnClientActive
from players import PlayerGenerator
from players.entity import Player


class PlayerCS(Player):
"""Modified Player class."""
caching = True

def change_skybox(self, sky_name):
"""Changes the appearance of the skybox for this player.

Args:
sky_name (str): A valid skybox. (e.g. 'cs_tibet')
"""
try:
self.send_convar_value('sv_skyname', sky_name)
except AttributeError:
# Can't send convars to GOTV/SourceTV.
pass


@OnClientActive
def on_client_active(index):
"""Called when a player joins the server."""
PlayerCS(index).change_skybox('sky_csgo_cloudy01')


@ServerCommand('change_skybox')
def change_skybox_command(command):
"""Changes the appearance of the skybox for all players on the server."""
try:
# Let's see if the name of the skybox was specified.
sky_name = command[1]
except IndexError:
# Nope, don't go further.
return

for edict in PlayerGenerator():
player = PlayerCS(index_from_edict(edict))

# Skip bots.
if player.is_bot():
continue

player.change_skybox(sky_name)
This won't work on all CSGO maps. Ever since the de_train remake (might be even before), the devs began using a different kind of skybox. Basically, they create a prop_static with a dome shaped model that surrounds the whole map, instead of just using brushes with the tools/skybox texture.
Here's what that skydome looks like on de_dust2:
Image

Since this skydome is a prop_static, there's absolutely nothing you can do to change it with Source.Python. The way I'd try to solve this would be to make my own dome model that's slightly smaller (can be adjusted with modelscale in-game) than the original with the sky texture I want, and just fine tune its origin until I get the desired result:
Image
I'm not even sure if this would work, but it's the first thing I'd try out.


Onto the lighting:

Syntax: Select all

# ../change_lighting/change_lighting.py

# Python
from enum import IntEnum

# Source.Python
from engines.server import engine_server
from listeners import OnLevelInit
from listeners.tick import Delay


class LightStyles(IntEnum):
"""Lighting styles found within the game engine."""
NORMAL = 0
FLICKER1 = 1
SLOW_STRONG_PULSE = 2
CANDLE1 = 3
FAST_STROBE = 4
GENTLE_PULSE = 5
FLICKER2 = 6
CANDLE2 = 7
CANDLE3 = 8
SLOW_STROBE = 9
FLUORESCENT_FLICKER = 10
SLOW_PULSE_NO_BLACK = 11
UNDERWATER = 12


def change_lighting(value, style=LightStyles.NORMAL):
"""Changes the style and intensity of the lighting on the server.

Args:
value (str): Intensity of the light. ('a' - darkest, 'z' - brightest)
style (int): Style of the light (see the LightStyles enum).

Note:
The value 'a' appears to be broken in CS:GO, use 'b' as the darkest
option.
This function should be called after the map has been changed, but
before any players have fully joined. Otherwise, the players will
have to reconnect to see the changes.
"""
engine_server.light_style(style, value)


@OnLevelInit
def on_level_init(map_name):
"""Called when a new map loads."""
# The change won't work without a short delay.
Delay(1, change_lighting, ('b',), cancel_on_level_end=True)
This should work without any issues.


Now let's talk about weather.
I've never messed around with weather effects with SP, but I have used func_precipitation when making maps. It can be a bit buggy, and as the wiki states - it's not accelerated by the GPU. So if you use a lot of these entities, your players are gonna have a bad time (performance wise).

You can't just slap one giant func_precipitation across the whole map and have it work properly. What about indoor areas of the map?
Image
Not to mention all the wasted performance on those unreachable/blocked off areas. So if you really wanted to use this entity, you'd either have to manually assign a few zones where the rain/snow/ash effect will take place, or you could generate these zones by using GameTrace() a whole bunch of times and save the data in a file for future use. Maybe you could get this information from nav files? I'm not sure.

In my opinion, there's a better way to achieve this, at least in CSGO. And that's particle effects! :grin: Just take a look at these effects:
(1: aztec_fog_volume_bottom, 2: cbbl_movie_fog, 3: storm_cloud_parent)
Image Image Image
There's a ton of effects already available in CSGO, and the best thing is - you can make your own!


Last but not least, the fog.
Messing around with fog is somewhat easy, you can see how I did it in the silent_hill plugin. You could even take the screen darkening part of the plugin, adjust it a bit, and have a decent blue tint screen effect. Although the screen effect can be done differently in CSGO, with postprocess_controller, color_correction, or.. you guessed it - particle effects. :tongue:

I hope this post helps, even if just a little.
ImageImageImageImageImage
User avatar
Grubbsy
Junior Member
Posts: 12
Joined: Sat Aug 29, 2020 10:12 pm

Re: [CSGO/ANY] Weather/Time Plugin.

Postby Grubbsy » Tue Nov 24, 2020 4:40 pm

Thanks! This helped out a lot!

I tested by making the map REALLY dark *light value was b* and changing the skybox to sky_lunacy for shits n giggles :)
I made a few minor edits like making the skybox a global variable so that it will constantly update for players when joining instead of returning the string set in the OnClientActive portion.

its like barely the same but,

Syntax: Select all

# ../change_skybox/change_skybox.py

# Source.Python
from commands.server import ServerCommand
from entities.helpers import index_from_edict
from listeners import OnClientActive
from players import PlayerGenerator
from players.entity import Player

# ----------------
# Skybox
# ----------------
global skyname

class PlayerCS(Player):
"""Modified Player class."""
caching = True

def change_skybox(self, sky_name):
"""Changes the appearance of the skybox for this player.

Args:
sky_name (str): A valid skybox. (e.g. 'cs_tibet')
"""
try:
self.send_convar_value('sv_skyname', sky_name)
except AttributeError:
# Can't send convars to GOTV/SourceTV.
pass


@OnClientActive
def on_client_active(index):
global skyname
"""Called when a player joins the server."""
PlayerCS(index).change_skybox(skyname)


@ServerCommand('change_skybox')
def change_skybox_command(command):
"""Changes the appearance of the skybox for all players on the server."""
global skyname
try:
# Let's see if the name of the skybox was specified.
skyname = command[1]
except IndexError:
# Nope, don't go further.
return

for edict in PlayerGenerator():
player = PlayerCS(index_from_edict(edict))

# Skip bots.
if player.is_bot():
continue

player.change_skybox(skyname)

I'll try and work on the fog and precip when I get back!


I really like your commitment to all the plugin requests!
Thanks!
Image
User avatar
VinciT
Senior Member
Posts: 331
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO/ANY] Weather/Time Plugin.

Postby VinciT » Tue Dec 01, 2020 6:18 am

Wow that looks really cool! And it's nice to see NamedNPC make an appearance as well. :grin:

Grubbsy wrote:I made a few minor edits like making the skybox a global variable so that it will constantly update for players when joining instead of returning the string set in the OnClientActive portion.
Good thinking!

Grubbsy wrote:I'll try and work on the fog and precip when I get back!
Can't wait to see how you implement the weather.

Grubbsy wrote:I really like your commitment to all the plugin requests!
Heh, I enjoy helping people out, and most of the time I learn something new while working on requests. I'm glad I was able to help you out.
ImageImageImageImageImage

Return to “Plugin Requests”

Who is online

Users browsing this forum: No registered users and 31 guests