Re: Ask a simple question, get a simple answer
Posted: Sat Jan 20, 2018 7:28 pm
Ok thanks!
Official Legend of Grimrock Forums
http://grimrock.net/forum/
Now I'm curious, because that shouldn't make a difference. Can I see the original object definition?AndakRainor wrote:Thanks! I found my mistake from those clues; in fact I merged the torch and wall definitions in one object for convenience. Doing this excludes the object itself from the shadow map calculation... I fixed it by spawning a separate wall object at the torch object initialisation instead!
Code: Select all
defineObject{
name = "ud_wall_torch",
baseObject = "base_wall",
components = {
{
class = "Model",
model = "mod_assets/vb/models/models_under_d/env/ud_wall_torch.fbx",
staticShadow = true,
},
{
class = "Light",
offset = vec(0, 1.4, -0.42),
range = 8,
color = vec(1.3, 0.68, 0.35),
brightness = 3,
castShadow = true,
shadowMapSize = 64,
staticShadows = true,
staticShadowDistance = 0, -- use static shadows always
onUpdate = function(self)
local noise = math.noise(Time.currentTime()*3 + 123) * 1 + 1.5
self:setBrightness(noise * 6)
end,
},
{
class = "Particle",
particleSystem = "ud_fire02",
offset = vec(0, 1.2, -0.42),
},
{
class = "Sound",
sound = "ud_fire_small",
},
{
class = "Model",
name = "wall",
model = "mod_assets/vb/models/models_under_d/env/ud_wall01_a.fbx",
staticShadow = true,
onInit = function(self)
local tab = {"a", "b", "c"}
self:setModel("mod_assets/vb/models/models_under_d/env/ud_wall01_"..tab[math.random(#tab)]..".fbx")
end,
},
{
class = "Occluder",
model = "assets/models/env/dungeon_wall_01_occluder.fbx",
},
},
editorIcon = 84,
minimalSaveState = true,
tags = { "VB","Under Dungeon" },
}
Code: Select all
defineObject{
name = "ud_wall_torch",
baseObject = "base_wall",
components = {
{
class = "Model",
model = "mod_assets/vb/models/models_under_d/env/ud_wall_torch.fbx",
staticShadow = true,
onInit = function(self)
local tab = {"a", "b", "c"}
self.go:spawn("ud_wall01_"..tab[math.random(#tab)])
end,
},
{
class = "Light",
offset = vec(0, 1.4, -0.42),
range = 8,
color = vec(1.3, 0.68, 0.35),
brightness = 3,
castShadow = true,
shadowMapSize = 64,
staticShadows = true,
staticShadowDistance = 0, -- use static shadows always
onUpdate = function(self)
local noise = math.noise(Time.currentTime()*3 + 123) * 1 + 1.5
self:setBrightness(noise * 6)
end,
},
{
class = "Particle",
particleSystem = "ud_fire02",
offset = vec(0, 1.2, -0.42),
},
{
class = "Sound",
sound = "ud_fire_small",
},
},
editorIcon = 84,
minimalSaveState = true,
tags = { "VB","Under Dungeon" },
}
Code: Select all
bolt.tiledamager:setAttackPower(200*(1+skill*0.25))
Code: Select all
defineSpell{
name = "light_bolt",
uiName = "Light Bolt",
gesture = 63258,
manaCost = 30,
skill = "arcane",
requirements = {"arcane", 1, "light_magic", 2},
icon = 58,
spellIcon = 18,
description = "Cast a bolt of pure light on your foes. Damage increase by 25% with arcane skill.",
onCast = function(champion,x,y,direction,elevation,skill)
local bolt = spawn("arcane_bolt",party.level,x,y,direction,elevation)
bolt.projectile:setIgnoreEntity(party)
-- bolt.tiledamager:setAttackPower(200*(1+skill*0.25))
local ord = champion:getOrdinal()
local left = nil
for i = 1,4 do
if party.party:getChampion(i):getOrdinal() == ord then
left = i == 1 or i == 3
break
end
end
local wpos = party:getWorldPosition()
local dx = nil
local dz = nil
if party.facing == 0 then
dx = left and -0.1 or 0.1
dz = -1
elseif party.facing == 1 then
dz = left and 0.1 or -0.1
dx = -1
elseif party.facing == 2 then
dx = left and 0.1 or -0.1
dz = 1
else -- party.facing == 3
dz = left and -0.1 or 0.1
dx = 1
end
bolt:setWorldPosition(vec(wpos[1]+dx,wpos[2]+1.35,wpos[3]+dz))
end,
}
defineObject{
name = "arcane_bolt",
baseObject = "base_spell",
components = {
{
class = "Particle",
particleSystem = "arcane_bolt",
},
{
class = "Light",
color = vec(1, 0.6, 1),
brightness = 7,
range = 5,
},
{
class = "Sound",
sound = "blob",
pitch = 0.5,
},
{
class = "Sound",
name = "launchSound",
sound = "arcane_launch",
onInit = function(self) self:setPitch(1.2+math.random()*0.6) end,
},
{
class = "Projectile",
spawnOffsetY = 1.15,
velocity = 25,
radius = 0.1,
hitEffect = "arcane_blast",
},
},
}
defineObject{
name = "arcane_blast",
baseObject = "base_spell",
components = {
{
class = "Particle",
particleSystem = "arcane_blast",
-- destroyObject = true,
},
{
class = "Light",
color = vec(1, 0.6, 1),
brightness = 10,
range = 7,
fadeOut = 0.5,
disableSelf = true,
},
{
class = "Sound",
sound = "blob_hit",
onInit = function(self) self:setPitch(1.2+math.random()*0.6) end,
},
{
class = "TileDamager",
attackPower = 100,
damageType = "pure",
sound = "blob_hit",
onInit = function(self)
-- Award experience.
self:setDamageFlags(DamageFlags.Champion1)
end
},
},
}
Yep. The shadow map only gets recomputed when the party is closer to the light than the staticShadowDistance, which for this light is 0, so it'll update once when the LightComponent first updates (and after every reload) and otherwise won't.AndakRainor wrote:the old one:the new one (fixes light through walls):Code: Select all
defineObject{ name = "ud_wall_torch", baseObject = "base_wall", components = { { class = "Model", model = "mod_assets/vb/models/models_under_d/env/ud_wall_torch.fbx", staticShadow = true, }, { class = "Light", offset = vec(0, 1.4, -0.42), range = 8, color = vec(1.3, 0.68, 0.35), brightness = 3, castShadow = true, shadowMapSize = 64, staticShadows = true, staticShadowDistance = 0, -- use static shadows always onUpdate = function(self) local noise = math.noise(Time.currentTime()*3 + 123) * 1 + 1.5 self:setBrightness(noise * 6) end, }, { class = "Particle", particleSystem = "ud_fire02", offset = vec(0, 1.2, -0.42), }, { class = "Sound", sound = "ud_fire_small", }, { class = "Model", name = "wall", model = "mod_assets/vb/models/models_under_d/env/ud_wall01_a.fbx", staticShadow = true, onInit = function(self) local tab = {"a", "b", "c"} self:setModel("mod_assets/vb/models/models_under_d/env/ud_wall01_"..tab[math.random(#tab)]..".fbx") end, }, { class = "Occluder", model = "assets/models/env/dungeon_wall_01_occluder.fbx", }, }, editorIcon = 84, minimalSaveState = true, tags = { "VB","Under Dungeon" }, }
That said, I have seen it next to secret doors, and it looks like the light does not update when the secret door opens. I guess it comes from staticShadows = true ?Code: Select all
defineObject{ name = "ud_wall_torch", baseObject = "base_wall", components = { { class = "Model", model = "mod_assets/vb/models/models_under_d/env/ud_wall_torch.fbx", staticShadow = true, onInit = function(self) local tab = {"a", "b", "c"} self.go:spawn("ud_wall01_"..tab[math.random(#tab)]) end, }, { class = "Light", offset = vec(0, 1.4, -0.42), range = 8, color = vec(1.3, 0.68, 0.35), brightness = 3, castShadow = true, shadowMapSize = 64, staticShadows = true, staticShadowDistance = 0, -- use static shadows always onUpdate = function(self) local noise = math.noise(Time.currentTime()*3 + 123) * 1 + 1.5 self:setBrightness(noise * 6) end, }, { class = "Particle", particleSystem = "ud_fire02", offset = vec(0, 1.2, -0.42), }, { class = "Sound", sound = "ud_fire_small", }, }, editorIcon = 84, minimalSaveState = true, tags = { "VB","Under Dungeon" }, }