Snowfall for Black Mesa
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Snowfall for Black Mesa
Could someone a snowfall plugin writing for Black Mesa?
Greeting Painkiller
Greeting Painkiller
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
I tested L'In20Cible's old snowfall addon with EventScripts on CS:S. Somehow, this was crashing my client when setting the precipitation model. Then I have also tested it with SP and it's crashing as well. We might need to figure out a new way of creating precipitation (or I was too tired yesterday and made a stupid mistake).
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Painkiller wrote:Hi mates,
could someone take a look at it again?
This works in CSGO for me, but as said crashes CSS with a C++ error message, maybe CSS does some optimisation @ map compile time?
I guess you could test this out in Black Mesa?
Syntax: Select all
from events import Event
from entities.entity import Entity
from entities.helpers import create_entity
from filters.entities import EntityIter
from engines.server import global_vars
from colors import Color
@Event("round_start")
def round_start(game_event):
for worldspawn in EntityIter("worldspawn"):
break
else:
raise NotImplementedError("No world on round start ~ wut?")
for func_precipitation in EntityIter("func_precipitation"):
if func_precipitation.get_key_value_int("preciptype") == 3:
break
else:
func_precipitation = Entity(create_entity("func_precipitation"))
func_precipitation.set_key_value_string("model", "maps/{0}.bsp".format(global_vars.map_name))
func_precipitation.set_key_value_int("preciptype", 3)
func_precipitation.set_key_value_int("renderamt", 255)
func_precipitation.color = Color(218, 243, 255)
func_precipitation.set_key_value_int("renderfx", 255)
func_precipitation.set_key_value_int("rendermode", 3)
func_precipitation.get_input("Alpha")(250)
func_precipitation.spawn()
func_precipitation.mins = worldspawn.get_property_vector("m_WorldMins")
func_precipitation.maxs = worldspawn.get_property_vector("m_WorldMaxs")
func_precipitation.origin = (func_precipitation.mins + func_precipitation.maxs) / 2
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
There is no round_start event in either of those games. Try using OnLevelInit instead (untested):
Syntax: Select all
from entities.entity import Entity
from entities.helpers import create_entity
from filters.entities import EntityIter
from colors import Color
from listeners import OnLevelInit
@OnLevelInit
def level_init(map_name):
for worldspawn in EntityIter("worldspawn"):
break
else:
raise NotImplementedError("No world on round start ~ wut?")
for func_precipitation in EntityIter("func_precipitation"):
if func_precipitation.get_key_value_int("preciptype") == 3:
break
else:
func_precipitation = Entity(create_entity("func_precipitation"))
func_precipitation.set_key_value_string("model", "maps/{0}.bsp".format(map_name))
func_precipitation.set_key_value_int("preciptype", 3)
func_precipitation.set_key_value_int("renderamt", 255)
func_precipitation.color = Color(218, 243, 255)
func_precipitation.set_key_value_int("renderfx", 255)
func_precipitation.set_key_value_int("rendermode", 3)
func_precipitation.get_input("Alpha")(250)
func_precipitation.spawn()
func_precipitation.mins = worldspawn.get_property_vector("m_WorldMins")
func_precipitation.maxs = worldspawn.get_property_vector("m_WorldMaxs")
func_precipitation.origin = (func_precipitation.mins + func_precipitation.maxs) / 2
- L'In20Cible
- Project Leader
- Posts: 1534
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
I think I would rather recommend using:satoon101 wrote:Syntax: Select all
@OnLevelInit
def level_init(map_name):
for worldspawn in EntityIter("worldspawn"):
break
else:
raise NotImplementedError("No world on round start ~ wut?")
Syntax: Select all
from entities.constants import WORLD_ENTITY_INDEX
@OnLevelInit
def level_init(map_name):
worldspawn = Entity(WORLD_ENTITY_INDEX)
And even if WORLD_ENTITY_INDEX didn't exist, I'd say using next() is much more Pythonic than for: breakL'In20Cible wrote:I think I would rather recommend using:Syntax: Select all
from entities.constants import WORLD_ENTITY_INDEX
@OnLevelInit
def level_init(map_name):
worldspawn = Entity(WORLD_ENTITY_INDEX)
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
satoon101 wrote:There is no round_start event in either of those games. Try using OnLevelInit instead (untested):Syntax: Select all
from entities.entity import Entity
from entities.helpers import create_entity
from filters.entities import EntityIter
from colors import Color
from listeners import OnLevelInit
@OnLevelInit
def level_init(map_name):
for worldspawn in EntityIter("worldspawn"):
break
else:
raise NotImplementedError("No world on round start ~ wut?")
for func_precipitation in EntityIter("func_precipitation"):
if func_precipitation.get_key_value_int("preciptype") == 3:
break
else:
func_precipitation = Entity(create_entity("func_precipitation"))
func_precipitation.set_key_value_string("model", "maps/{0}.bsp".format(map_name))
func_precipitation.set_key_value_int("preciptype", 3)
func_precipitation.set_key_value_int("renderamt", 255)
func_precipitation.color = Color(218, 243, 255)
func_precipitation.set_key_value_int("renderfx", 255)
func_precipitation.set_key_value_int("rendermode", 3)
func_precipitation.get_input("Alpha")(250)
func_precipitation.spawn()
func_precipitation.mins = worldspawn.get_property_vector("m_WorldMins")
func_precipitation.maxs = worldspawn.get_property_vector("m_WorldMaxs")
func_precipitation.origin = (func_precipitation.mins + func_precipitation.maxs) / 2
This Error come on
Half Life 2 Deathmatch and Black Mesa Source
Syntax: Select all
18:02:26 [SP] Loading plugin 'snow'...
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/plugins/manager.py', line 71, in __missing__
instance = self.instance(plugin_name, self.base_import)
File '../addons/source-python/packages/source-python/plugins/instance.py', line 82, in __init__
self._plugin = import_module(import_name)
File '../addons/source-python/plugins/snow/snow.py', line 5, in <module>
from listeners import OnLevelInit
ImportError: cannot import name 'OnLevelInit'
[SP] Plugin 'snow' was unable to be loaded.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
I did test some code, but it only seemed to work on CS:GO. It isn't that it didn't "work" on CS:S, HL2:DM, or BM:S, it actually crashed my client on all 3. If I can get that figured out and fixed, I will post some code. Note that I will certainly test on both BM:S and HL2:DM before posting working code (if I can figure it out).
*Edit: I narrowed down the crashing of the client, but I really don't know why it does it. Here is my test script:
If I comment out setting the model, the client does not crash, but there is no effect. This code works perfectly on CS:GO. If I comment out setting the model in CS:GO, the effect does not show. So, setting the model is necessary, but crashes the client on CS:S, HL2:DM, and BM:S (probably DOD:S and TF2, as well).
*Edit2: I did notice that in this addon, sicman_adrian uses env_smokestack instead of func_precipitation. This requires multiple entities to be created and for locations to be specified in data files. I will do some testing to see if that works on all games.
*Edit: I narrowed down the crashing of the client, but I really don't know why it does it. Here is my test script:
Syntax: Select all
from colors import Color
from entities.constants import WORLD_ENTITY_INDEX
from entities.entity import Entity
from engines.precache import Model
from engines.server import global_vars
from events import Event
from listeners import OnLevelInit
from listeners.tick import tick_delays
@OnLevelInit
@Event('round_start')
def create_snow(*args):
try:
worldspawn = Entity(WORLD_ENTITY_INDEX)
except ValueError:
tick_delays.delay(0, create_snow)
return
func_precipitation = Entity.find_or_create("func_precipitation")
func_precipitation.model = Model("maps/{0}.bsp".format(global_vars.map_name))
func_precipitation.precip_type = 3
func_precipitation.color = Color(218, 243, 255)
func_precipitation.render_mode = 3
func_precipitation.spawn()
func_precipitation.mins = worldspawn.world_mins
func_precipitation.maxs = worldspawn.world_maxs
origin = (func_precipitation.mins + func_precipitation.maxs) / 2
func_precipitation.origin = origin
create_snow()
If I comment out setting the model, the client does not crash, but there is no effect. This code works perfectly on CS:GO. If I comment out setting the model in CS:GO, the effect does not show. So, setting the model is necessary, but crashes the client on CS:S, HL2:DM, and BM:S (probably DOD:S and TF2, as well).
*Edit2: I did notice that in this addon, sicman_adrian uses env_smokestack instead of func_precipitation. This requires multiple entities to be created and for locations to be specified in data files. I will do some testing to see if that works on all games.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
- L'In20Cible
- Project Leader
- Posts: 1534
- Joined: Sat Jul 14, 2012 9:29 pm
- Location: Québec
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: Snowfall for Black Mesa
Is there any new information?
Code: Select all
18:51:38 sp plugin load snow
18:51:38 [SP] Loading plugin 'snow'...
[SP] Caught an Exception:
Traceback (most recent call last):
File "../addons/source-python/packages/source-python/plugins/command.py", line 162, in load_plugin
plugin = self.manager.load(plugin_name)
File "../addons/source-python/packages/source-python/plugins/manager.py", line 193, in load
plugin._load()
File "../addons/source-python/packages/source-python/plugins/instance.py", line 74, in _load
self.module = import_module(self.import_name)
File "../addons/source-python/plugins/snow/snow.py", line 8, in <module>
from listeners.tick import tick_delays
ImportError: cannot import name 'tick_delays'
[SP] Plugin 'snow' was unable to be loaded.
Re: Snowfall for Black Mesa
That exception is unrelated to the crash mentioned in the previous posts. And since there haven't been any updates to HL2DM I highly doubt it's now working without crashing.
- Painkiller
- Senior Member
- Posts: 726
- Joined: Sun Mar 01, 2015 8:09 am
- Location: Germany
- Contact:
Re: Snowfall for Black Mesa
This is the current error code when I loaded it.
Who is online
Users browsing this forum: No registered users and 7 guests