Ask a simple question, get a simple answer
-
- Posts: 34
- Joined: Sun Mar 08, 2015 1:45 am
Re: Ask a simple question, get a simple answer
Hello all. Quick question about the momentum of thrown objects through teleporters. I have a teleporter set up with a script that moves the teleport target location every second or so as part of a puzzle. But the momentum of items thrown through is finicky. Throwing weapons (like shuriken) work fine (as do missile weapons), but other items thrown manually with the mouse just plop the item on the floor at the teleporter target's exact location when thrown through - the momentum isn't maintained. The puzzle can still be solved with throwing weapons/missile weapons as I mentioned, but it seems a bit buggy that manually thrown items don't work. Is this normal? Is there a way to fix it? Aside from this everything works fine so its not game-breaking, it just looks like something isn't working right. Cheers.
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
Can anyone explain why the torch light goes through walls on the following picture? (but not pillars!)
Is there a way to fix it?
Is there a way to fix it?
SpoilerShow
Re: Ask a simple question, get a simple answer
Two possibilities:
1. The ModelComponent for the wall the torch is on is missing staticShadow = true (or, less likely, the model or material has shadow casting disabled entirely)
2. The models are set up fine, but the light source is too close to the wall the torch is on -> shadowmap doesn't catch that wall (its resolution is too low) -> shadowmap doesn't catch the other wall because the triangles are one-sided -> light makes it through both walls without casting a shadow. The pillar has some distance from the light source, so it shows up in the shadowmap.
Judging by the shadow of the pillar, it looks like the light source has decent distance from the wall, so it's probably option 1.
1. The ModelComponent for the wall the torch is on is missing staticShadow = true (or, less likely, the model or material has shadow casting disabled entirely)
2. The models are set up fine, but the light source is too close to the wall the torch is on -> shadowmap doesn't catch that wall (its resolution is too low) -> shadowmap doesn't catch the other wall because the triangles are one-sided -> light makes it through both walls without casting a shadow. The pillar has some distance from the light source, so it shows up in the shadowmap.
Judging by the shadow of the pillar, it looks like the light source has decent distance from the wall, so it's probably option 1.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
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!
Re: Ask a simple question, get a simple answer
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!
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
the old one:
the new one (fixes light through walls):
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,
},
{
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" },
}
Re: Ask a simple question, get a simple answer
please can someone explain how to increase damage of a projectile with its base magic skill? I want that the projectile gain 25% damage for each arcane skill.
I've tried with
but that don't work, the tiledamager is not recognized trough the projectile.
here is the spell:
I've tried with
Code: Select all
bolt.tiledamager:setAttackPower(200*(1+skill*0.25))
here is the spell:
SpoilerShow
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
},
},
}
Re: Ask a simple question, get a simple answer
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" }, }
In your original definition, the wall ModelComponent appears after the LightComponent, which means it'll be created after the LightComponent, and I guess the LightComponent is updating before that happens. The new definition has the wall model created prior to the LightComponent, so it fixes this issue, but I think simply moving the wall ModelComponent up in the original definition would also work.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- AndakRainor
- Posts: 674
- Joined: Thu Nov 20, 2014 5:18 pm
Re: Ask a simple question, get a simple answer
Oh I did not think about the order! And I just realize now that this is a minimalSaveState object, so the new code will spawn many walls XD
@bongobeat: you could look at objects.lua in the spells pack to see how I solved this.
@bongobeat: you could look at objects.lua in the spells pack to see how I solved this.