Re: Ask a simple question, get a simple answer
Posted: Sat Dec 14, 2024 3:26 am
Found the potion Thanks
Official Legend of Grimrock Forums
http://grimrock.net/forum/
This is not a simple question. It is probably the most complicated question that has ever been asked in Grimrock modding. But I guess I might as well answer it here anyway.Slava wrote: ↑Tue Dec 17, 2024 11:59 am Is there any way to check how much the party object or tile underneath it is lit?
i.e. is it in the shade or in the sun?
I understand that there are dynamic shadows under the open sky during the day and it is difficult to implement. But i want to neglect this. Just having day and night. I want to find a way (maybe someone already has it) how to determine the degree of light in the dungeon? Let's say there is a monster. I can getSight its component brain then depending on getAllAroundSight() check if it is looking towards the party. And this functionality I want to extend. We can always check seesParty, so I want to reduce the Sight of all monsters in the level depending on the lighting of the party.
What I'm envisioning. I need to get all the light components in the level, and then depending on getType() check getDirection(), getRange() and maybe getSpotAngle(), getSpotSharpness(). I have no idea what the last two do.
But I hope that all this is needed and can be done in a simpler way. After all, the game somehow understands what part of the texture is illuminated.
In that case, thank you very much for your reply Minmay!It is probably the most complicated question that has ever been asked in Grimrock modding.
Unfortunately I don't have access to steam (don't want to) and don't have access to umod. I have seen the source code though, and a way to modify it without using umod. The whole thing really seems horrible to me. Despite being a bit of a programmer, I'm not a game developer. I have no idea how to implement this.One is to use a umod
I haven't found anything that allows raytracing to be used in a game or mod. Even if this functionality is there, I don't see a way to control it other than again climbing into the source code of the game.cast a ray to the party
I was also thinking about the third option. It seems more realistic to me. There is no problem to design a dungeon so that then manually set the light level. I see it the same way we draw a map of heights, noise and reflections.3. designing your dungeon's levels, spells, monsters, etc.
That's something I already agree with.4. have your code just guess how much lighting the party is in and regularly get it completely wrong
My goal is to add stels mechanics everywhere, not just where it may have been planned and programmed. I think that would be interesting for players.I don't think these are real options because the only reason you'd consider adding this mechanic in the first place is that you want to actually do something with it, with moving light sources and shadows (rules out 3.) and the lighting value actually mattering to the player (rules out 4.)
I'm not talking about ray tracing, this is much more primitive than that: just checking if a ray would intersect any of the aforementioned shapes at a distance smaller than its distance to the party's position.
Code: Select all
local altar = spawn("altar", self.go.level, self.go.x, self.go.y + dy, self.go.facing, self.go.elevation, "s_" .. "altar" .. "_" .. s)
altar.surface:addItem(spawn(item).item)
Code: Select all
for e in self.go.map:entitiesAt(self.go.x, self.go.y + dy) do
if e.surface then
print(e.id) -- it prints the id of the altar I just spawned
e.surface:addItem(spawn(item).item)
break
end
end
Code: Select all
local altar = findEntity(altarId)
if altar then
altar.surface:addItem(spawn("blue_gem").item)
end
What's the value of the "item" variable?7Soul wrote: ↑Tue Dec 24, 2024 7:37 pm But this causes an exception saying addItem requires an ItemComponent:Code: Select all
e.surface:addItem(spawn(item).item)
It works if I spawn it outside of the loop. If I spawn the altar and then spawn the item on it it's fine. If I spawn the altar and then use entitiesAt to find the altar, it doesn't work. And as you can see in the code, the loop does find the altar and does call addItem but the function doesn't recognize the ItemComponentZo Kath Ra wrote: ↑Tue Dec 24, 2024 11:08 pmWhat's the value of the "item" variable?7Soul wrote: ↑Tue Dec 24, 2024 7:37 pm But this causes an exception saying addItem requires an ItemComponent:Code: Select all
e.surface:addItem(spawn(item).item)
If the "item" variable has the wrong value, then the spawned entity will not have an item component.
Maybe add a "print(item)" to the loop?
Code: Select all
for obj in self.go.map:entitiesAt(self.go.x, self.go.y) do
print(obj.name, obj.id) -- prints nil, and the correct id of the obj
end
Code: Select all
local ob = spawn("blue_gem")
print(obj.name, obj.id) -- prints "blue_gem, blue_gem_1"
Try this
Code: Select all
local gem = "blue_gem"
for e in self.go.map:entitiesAt(self.go.x, self.go.y + dy) do
if e and e.surface then
local o = spawn(gem).item
e.go.surface:addItem(o)
break
end
end