Questions about DSB/ESB
Moderator: Sophia
Forum rules
Please read the Forum rules and policies before posting.
Please read the Forum rules and policies before posting.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Yeah, that's probably why I will avoid it. I can do basic stuff, but I'm not about to start ripping into the AI code...
For passive wandering monsters, I think it would work to spawn a new critter on their death, so if the party kills them by walking into them, a new one is generated behind the party. Might work, I'll test it out.
For passive wandering monsters, I think it would work to spawn a new critter on their death, so if the party kills them by walking into them, a new one is generated behind the party. Might work, I'll test it out.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Couple more questions:
1) Is there a way of preventing items being placed on tiles containing a pillar? With large pillars, it looks really weird that items sit on top of them when really there wouldn't be enough room.
2) For wallsets, which is drawn first: the ceiling or the floor?
1) Is there a way of preventing items being placed on tiles containing a pillar? With large pillars, it looks really weird that items sit on top of them when really there wouldn't be enough room.
2) For wallsets, which is drawn first: the ceiling or the floor?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
It seems like the easiest way to handle this would be to treat the square as a wall but tell not actually draw a wall. I'll figure out the best way to make that approach work.Gambit37 wrote:Is there a way of preventing items being placed on tiles containing a pillar? With large pillars, it looks really weird that items sit on top of them when really there wouldn't be enough room.
Ceiling first, then the floor.Gambit37 wrote:For wallsets, which is drawn first: the ceiling or the floor?
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
I've been experimenting with saving variables in a save game. You prevously suggested I do something like this in my startup:
During game play those variables might become pointers to sound entries, something like:
When re-loading a save game that stored these variables, DSB complains with:
These are the functions used to play the footstep sounds, which work fine normally, but fail when restoring a save game:
I'm not really understanding why this isn't working. Should I be using the format "snp_data.sound_feet" or "snp_data[sound_feet]" to get the contents of these table entries? Either way, it doesn't seem to work.
I don't really know what I'm doing
Code: Select all
dsb_export("snp_data")
snp_data = {
sound_feet = 0,
sound_ambient = 0
}
Code: Select all
snp_data = {
sound_feet = snd.feet_on_stone
sound_ambient = snd.ambient_wind
}
Code: Select all
PROGRAM CRASH!
Location: 10 10 19
Reason: FMOD error 36
An invalid parameter was passed to this function.
Stack Dump:
DSBmain
DSBgameloop
run_timers
lua.dsb_3dsound
play_3dsound
Code: Select all
snd.feet_stone = { } -- Declare it as a table
for num=1,4 do
snd.feet_stone[num] = dsb_get_sound("FEET_ROCK" .. num, path .. "FTROC_P" .. num .. ".wav")
end
function snd_footsteps(sound)
local lev, x, y, face = dsb_party_coords()
dsb_delay_func(1, function() dsb_3dsound(sound[dsb_rand(1, 4)], lev, x, y) end)
end
function h_party_move(have_party, delay)
snd_footsteps(snp_data.sound_feet)
return delay
end
I don't really know what I'm doing
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
You can't save table references like that. The snd table gets created anew every time you run DSB.
The references when you reload are invalid (because pointers have moved etc.), which is why DSB crashes.
What you can do is store the names as strings, such as:
Then do:
The references when you reload are invalid (because pointers have moved etc.), which is why DSB crashes.
What you can do is store the names as strings, such as:
Code: Select all
snp_data.sound_feet = "feet_on_stone"
Code: Select all
function snd_footsteps(sound_name)
local sound = snd[sound_name]
local lev, x, y, face = dsb_party_coords()
dsb_delay_func(1, function() dsb_3dsound(sound[dsb_rand(1, 4)], lev, x, y) end)
end
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Cool, it worked, thank you
As you may have noticed, I do get rather confused between table references, asset pointers and properties of archs....
As you may have noticed, I do get rather confused between table references, asset pointers and properties of archs....
Re: Questions about DSB/ESB
All sounds as clear as mud to me!
Seriosuly though ,for someone who seemed to have been scared of any form of programming in this mode a year or less ago, you seem to be making enticing strides. Can't wait to see your work finalyl get shown off one of these days
Hopefully it might encourage other people who feel similarly, and that is the only reason they don't undertake their own dungeon
Seriosuly though ,for someone who seemed to have been scared of any form of programming in this mode a year or less ago, you seem to be making enticing strides. Can't wait to see your work finalyl get shown off one of these days
Hopefully it might encourage other people who feel similarly, and that is the only reason they don't undertake their own dungeon
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
I just push stuff about until it works... with lots of help from Sophia, of course! But thanks, yeah, I do feel I'm finally getting somewhere.... still a long way to go though.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Is there any sort of shading adjustment that can be applied to floor and wall decorations at different view distances? Once you start using the level tinting options, the automatic shading can cause some strange problems with decorative items no longer blending correctly at different distances.
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
What sort of shading adjustment? What problems are you having?
Right now, there isn't really anything that can be adjusted, because it always sort of "just worked" so far. But, of course, what I'd end up opening up to customization depends on what you feel doesn't look right.
Right now, there isn't really anything that can be adjusted, because it always sort of "just worked" so far. But, of course, what I'd end up opening up to customization depends on what you feel doesn't look right.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
I can't work out how to use on_expire and convert_expire. Well, I mean, adding them into the arch is obvious enough, but where do I set the countdown timer for the expire message to be fired?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
It doesn't quite work like that. It's based on an expire message, so you set the timer (so to speak) by adding a delay to the expire message.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Ah, right OK. I've been avoiding the whole area of messages so far and focusing on easy stuff. Looks like I can't avoid it any more
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
Well, it's not hugely difficult.
There are two events that might interest you.
on_spawn is called when an instance of that archetype is created.
on_init is called when an instance of the archetype is first initialized, whether that's a spawn or a dsb_swap.
(Note that this is a full swap. Neither function is called after a qswap, because that simply changes an instance's archetype and nothing else)
So, here's some simple code:
If you set one of the above two properties (preferably on_init, but your mileage may vary) to expire_after_delay and set expire_delay as either an arch property or an exvar for a given instance, that will do what you want.
There are two events that might interest you.
on_spawn is called when an instance of that archetype is created.
on_init is called when an instance of the archetype is first initialized, whether that's a spawn or a dsb_swap.
(Note that this is a full swap. Neither function is called after a qswap, because that simply changes an instance's archetype and nothing else)
So, here's some simple code:
Code: Select all
function expire_after_delay(arch, id)
local exp_delay = arch.expire_delay
if (exvar[id] and exvar[id].expire_delay) then
exp_delay = exvar[id].expire_delay
end
dsb_msg(exp_delay, id, M_EXPIRE, 0)
end
Code: Select all
-- instances of my_obj will receive an expire message after 20 ticks
obj.my_obj.on_init = expire_after_delay
obj.my_obj.expire_delay = 20
obj.my_obj.on_expire = do_something_else
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Aha, very nice, thank you
While documenting Things, I came across this which made me ponder: One can specify stat and stat_up to boost a statistic. Do these only accept a single value, or can they take an array, eg:
While documenting Things, I came across this which made me ponder: One can specify stat and stat_up to boost a statistic. Do these only accept a single value, or can they take an array, eg:
Code: Select all
stat = {STAT_DEX, STAT_WIS, STAT_STR},
stat_up = {10,20,30}
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
Currently, they can't. But I like that.
I'll hack that into the base code for 0.55.
I'll hack that into the base code for 0.55.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Is there a way of altering the positions of items drawn inside alcoves, at all 3 distances?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
Not at present.
Tell me what you'd like to do and I can probably make something work.
(PM it if you'd like)
Tell me what you'd like to do and I can probably make something work.
(PM it if you'd like)
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
I have a larger altar and the positions of contained items need to be adjusted to match it's shelf. I couldn't do it if I clone an alcove, so I tried it with two items: a simple decoration and a transparent alcove over the top. No matter how I adjust the tweak values for the mid and far views, the alcove position does not change. Do they work differently from normal wall items or am I doing something wrong?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
I think they're probably bugged. The code to generate the position for items drawn in an alcove is kind of a weird exception and it's off in its own little place in the renderer. I'll look into it and fix it for 0.55, probably.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Is it possible to draw graphics and text directly into the viewport? If not, what would be the best way of doing that?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
The best way would probably be either as a condition that defines an overlay, or by defining your own custom zone in gui_info.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
How do I add extra stuff to functions attached to a monster, such as on_die=setup_food_drop or on_move=monster_step?
Is it simply ok to move that function call into my custom function and call that instead, for example:
What if I wanted to modify *every* monsters on_move code so that every monster has something extra happen when they move? Do I just copy the function from base code and modify it?
Also, how would I add extra features to every monster's death -- would I need to copy all those setup_drop functions and add my features in there or is there a cleaner way?
Finally, I noticed the animation_timer in ESB. How does this work, and can I set it in code? For example, is it something I can set when a monster spawns to make sure it's timers dont't match other critters? I'm still seeing animations happening the same on groups of creatures, looks like they're dancing in time together
Is it simply ok to move that function call into my custom function and call that instead, for example:
Code: Select all
(arch definition)
on_move = handle_move
(end arch definition)
function handle_move(arch,id,group_leader)
monster_step(arch, id, group_leader)
... more code ....
end
Also, how would I add extra features to every monster's death -- would I need to copy all those setup_drop functions and add my features in there or is there a cleaner way?
Finally, I noticed the animation_timer in ESB. How does this work, and can I set it in code? For example, is it something I can set when a monster spawns to make sure it's timers dont't match other critters? I'm still seeing animations happening the same on groups of creatures, looks like they're dancing in time together
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Also, you previously mentioned changing the speed of spells and missiles using dsb_set_flyreps(). It's listed in the Wiki, but with no details, and I can't find an example anywhere in the base code -- could you provide some info on how to do this and I'll update the Wiki?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
Yes, that is perfectly fine.Gambit37 wrote:How do I add extra stuff to functions attached to a monster, such as on_die=setup_food_drop or on_move=monster_step?
Is it simply ok to move that function call into my custom function and call that instead
Yes, or write your own with a wrapper like you did there.Gambit37 wrote:What if I wanted to modify *every* monsters on_move code so that every monster has something extra happen when they move? Do I just copy the function from base code and modify it?
Remy discovered a trick a while ago for overriding functions that's a little weird but can save your some headaches:
Code: Select all
orig_monster_step = monster_step
function monster_step(self, id, group_leader)
-- Your code here
orig_monster_step(self, id, group_leader)
-- Put more code here
end
The cleanest way is probably to write your own h_monster_died. Take a look at base/hooks.lua.Gambit37 wrote:Also, how would I add extra features to every monster's death -- would I need to copy all those setup_drop functions and add my features in there or is there a cleaner way?
The timer counts ticks, not frames or anything like that. So you'll have to set it to a high enough number depending on how many ticks each frame of your animation lasts.Gambit37 wrote:Finally, I noticed the animation_timer in ESB. How does this work, and can I set it in code? For example, is it something I can set when a monster spawns to make sure it's timers dont't match other critters?
You can set it in code via dsb_set_animtimer(id, value)
(If you set the timer in ESB, you can see this function call in the saved dungeon.lua)
It's just dsb_set_flyreps(id, repetitions), where id must be an instance that is currently flying through the air. It will then execute its flying code repetitions times every time it updates. The default value is 1, of course, but setting it to a higher value will make fast or "instant hit" missiles.Gambit37 wrote:Also, you previously mentioned changing the speed of spells and missiles using dsb_set_flyreps(). It's listed in the Wiki, but with no details, and I can't find an example anywhere in the base code -- could you provide some info on how to do this and I'll update the Wiki?
At some point, I was going to add a flyreps property to object archs (or maybe attack methods?) to make this easier to invoke as part of the base code, but I apparently forgot to do that.
- Gambit37
- Should eat more pies
- Posts: 13718
- Joined: Wed May 31, 2000 1:57 pm
- Location: Location, Location
- Contact:
Re: Questions about DSB/ESB
Great, thanks for all the info.
Another question: how do I find out the open/closed state of a door (assuming I already have its inst ID). Also, if it's opening or closing?
That would be really useful. Otherwise, I imagine the best way of using it would be to call dsb_set_flyreps() through an arch property like on_spawn?I was going to add a flyreps property to object archs (or maybe attack methods?) to make this easier to invoke as part of the base code
Another question: how do I find out the open/closed state of a door (assuming I already have its inst ID). Also, if it's opening or closing?
- Sophia
- Concise and Honest
- Posts: 4240
- Joined: Thu Sep 12, 2002 9:50 pm
- Location: Nowhere in particular
- Contact:
Re: Questions about DSB/ESB
If a door is open, it's inactive. So a call to dsb_get_flag(id, GF_INACTIVE) which will return true if the door is open. As for whether the door is moving, an exvar called door_state will be nil if the door is open or closed, 1 if the door is opening, and 2 if the door is closing.