First of all, in lightning.lua, the lightning prefab is playing a sound on prefab pristine state. I'm pretty sure this ends up playing at 0, 0, 0 and can't be heard in most cases. Remote clients might not even be able to hear it at all.
local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() inst.entity:AddSoundEmitter() inst.Transform:SetScale(2, 2, 2) inst.AnimState:SetBloomEffectHandle("shaders/anim.ksh") inst.AnimState:SetLightOverride(1) inst.AnimState:SetBank("lightning") inst.AnimState:SetBuild("lightning") inst.AnimState:PlayAnimation("anim") inst.SoundEmitter:PlaySound("dontstarve/rain/thunder_close", nil, nil, true) inst:AddTag("FX") --Dedicated server does not need to spawn the local sfx if not TheNet:IsDedicated() then inst:DoTaskInTime(0, PlayThunderSound) end
The networked entity shouldn't be using a sound emitter at all anyhow, the delayed PlayThunderSound call takes care of handling the sound locally for non-dedicated instances.
Another issue is that, if lightning is too far away, no sound plays at all, which is weird given that thunder_close and thunder_far are global despite having no physical location.
local function PlayThunderSound(lighting) if not lighting:IsValid() or TheFocalPoint == nil then return end local pos = Vector3(lighting.Transform:GetWorldPosition()) local pos0 = Vector3(TheFocalPoint.Transform:GetWorldPosition()) local diff = pos - pos0 local distsq = diff:LengthSq() local k = math.max(0, math.min(1, distsq / LIGHTNING_MAX_DIST_SQ)) local intensity = math.min(1, k * 1.1 * (k - 2) + 1.1) if intensity <= 0 then return end
All of the above also applies to the moonstorm_lightning prefab.
Also, the thunder prefab from lightning.lua lacks the FX tag.
I feel like all of these could be using NOBLOCK and NOCLICK as well.
All this aside, I do have to point out there's some weird inconsistencies with all these lightning and thunder prefabs.
For starters, it would probably help to consolidate all of these prefabs into a single file, and have them share functionality as needed. Some of them are way too similar to have so many separate files.
Let's start with thunder_far:
- Has no physical location.
- No screen flash.
- Sound plays from a randomized direction that gets synced for everyone.
- Sound volume is the same for everyone and plays at full volume.
Then, there's thunder_close:
- Has no physical location.
- Screen flashes for everyone the same.
- Sound plays from a randomized direction that gets synced for everyone.
- Sound volume is the same for everyone and plays at full volume.
Then, lightning, moonstorm_lightning, and thunder (same as lightning, but without an anim state):
- Have a physical location.
- Screen flashes only for players within 140 units. It also only applies locally, meaning no flash on the server if it's dedicated. No flash on the server means ambient lighting isn't actually affected.
- Sound only plays for players within 140 units.
- Sound volume scales down the further away the player is.
So, the main things that could be looked at from those things mentioned above are:
-
Screen flash needs to be consistent. Currently, being too far away from lightning, thunder and moonstorm_lightning results in no screen flash, but even outside of that. It's weirdly inconsistent with affecting the world, unlike thunder_close, which always affects it and affects everyone the same.
- Maybe have all (except thunder_far) affect ambient lighting through the server? Otherwise you're gonna have to come up with some way for it to make sense. Could have it scale down to a minimum but always show, and have it apply on the dedicated server instance with the minimum value maybe.
- Players should still only get camera shake based on proximity with the ones with a physical location, and none otherwise.
-
Currently, somehow, lightning, thunder and moonstorm_lightning can be completely silent for far away players, while thunder_close plays at full volume always. Maybe:
- Have it so the sound can play regardless for them, but at a capped low volume, after all, thunder_close currently plays at full volume regardless (despite being delayed to make it sound like it's still a bit far away). And if far away enough, have the sound also be delayed like thunder_close.
- Have thunder_close always play its sound at that same minimum volume, since it's always intended to be far away enough, but not super far like thunder_far.
For the sound and screen flash inconsistencies:
-
Force dangerous lightning to spawn near a player very far away from you. Have them be on the other side of the world if you wanna be sure.
- Can be the following prefabs: lightning, thunder, or moonstorm_lightning.
- Preferably, use c_spawn instead of firing a component that weather listens to.
- Notice how you won't hear or see any indication of lightning.
- Now spawn thunder_close. It doesn't need a location and is global, so you can just use SpawnPrefab instead of c_spawn.
- Notice how not only you'll get screen flash, but it'll also be very loud.
For the ambient lighting issues:
- Be in complete darkness.
- Try spawning dangerous lightning near you. Then thunder_close.
-
Notice that only thunder_close will make you count as being in light momentarily.
- When testing this with dangerous lightning, do this as a remote player in a dedicated server. If it's a single shard world, the world will light up if the host player is close to the lightning.
Anything else that was explained in the report is self-explanatory.
-
1
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now