Tutorials: wallsets and custom monsters, objects, etc

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting. You may Image to help finance the hosting costs of this forum.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Gambit37 wrote: Tue Feb 04, 2025 12:00 pm My project has ended up a mixture of stuff in the graphics.cfg and then a ton of new stuff organised via chunked files called in the manifest. It's pretty messy and could do with an overhaul. With hindsight, I should have used the graphics.cfg for all the direct replacements, and then only added new files for new custom graphics that don't map to the existing images. Another way is to not use the graphics.cfg at all and instead specify everything in custom new override files (which is how I originally started) but that seems to increase loading time.

Right now I've got such a messy mixture that I can't remember where anything is, and this is one reason why I'm struggling to restart the project: do I spend time reorganising with the benefit of hindsight, or just leave it chaotic and finish everything that's missing and broken first? No right or wrong answer really, I guess we all just find ways that work for us...?
Yep. Luckily I’ve been good an organising my files (a world first) and attempting this graphics.cfg approach has made me tighten up more still (assuming I can get it to work). It was bugging me just dumping all the files ‘loose’ in the main project location. Sounds like you’ve got a more advanced technique in place? But a little slower to load?
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

First of all, writing absolute paths like that is a bad idea. Nobody will be able to play your dungeon unless they install it to the exact same place. You should use relative paths instead.

Anyway, I think what isn't working here is that you've used backslashes (\) which, in Lua, are used for escaping characters. It sees the \00 which, in C is a string terminator. So the string ends there and you just have the "X:". Anyway, a backslash is how Windows does file paths but Lua (along with most of the rest of the civilized world) uses forward slashes (/) in its paths. So try replacing all of the \ with / and see how that works.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Thanks, I did try that, but it had the same result, abeit with an error message saying that bitmap isn't found, here it would list the whole path in the error.
Image

Relative paths: meaning relative to DSB folder? So instead of:

Code: Select all

"X:/00_DM_Project_2025/DSB_DarkHalls/DUNGEON/DH_GFX/05_MONSTERS/SENTINEL_01.PNG"
Do you mean...?

Code: Select all

"DSB_FOLDER/DUNGEON/DH_GFX/05_MONSTERS/SENTINEL_01.PNG"
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

Right, relative to DSB (or wherever the dungeon is installed) so it will work for people who have it installed somewhere other than a specific location on the X: drive, like you have it now.

Anyway, the result is not the same: now it's showing the (presumably) correct path, which is progress. The next step is probably to determine if the bitmap itself is at fault. Unfortunately, Allegro 4's error reporting is not the best, so DSB will report that a bitmap is "not found" even if it can open the bitmap but can't load it. Has DSB successfully loaded that bitmap before? Do you get the same issue if you replace it with a bitmap that is known to work?
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

That bitmap works when I load it into a dungeon normally - ie, not via the graphics.cfg method, so it does work with DSB. I've copied a different .png file and renamed it to the same as the 'problem' file .png, but that doesn't work either, the error is reporting the same.

Do I need to 'declare' the graphics.cfg anywhere? Or just have it present in the folder?
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

Just having graphics.cfg present is enough.

Unfortunately, I think I've just about reached the limit of my ability to troubleshoot this problem remotely. Please zip up your files and send me the dungeon, or some portion thereof that is able to reproduce the issue.
User avatar
Gambit37
Should eat more pies
Posts: 13769
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Gambit37 »

It's easier just to have all your graphics within a subfolder of your project and use relative paths. So if your project is at X:/Project then stick all your images in X:/Project/gfx and reference them like this:

In graphics.cfg:

Code: Select all

DAGGER  = "gfx/things/weapons/dagger.png",
In a custom file through the manifest:

Code: Select all

path = "gfx/ui/"
gfx.splashscreen = dsb_get_bitmap(path .. "splashscreen")
gfx.entrance = dsb_get_bitmap(path .. "entrance")
gfx.entrance_fg = dsb_get_bitmap(path .. "entrance_fg")
This isn't technically 'correct' since I don't use shortnames, but it works just fine. Note that you don't need to specify the extension most of the time either.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ok many thanks both. Sophia, I’ll get something prepped tomorrow and PM you, thank you!
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

Ok, reading Gambit's post made think about how DSB is actually doing this and made me realize that your paths are still wrong. (Thanks for the help, Gambit :mrgreen: )

All paths are relative to the dungeon's main folder. If your dungeon is installed at X:/DSB/Project/, then if you want to load X:/DSB/Project/gfx/pics/mypic.png, then the correct path will be "gfx/pics/mypic.png" to properly load this image. If you put something like "DSB/Project/gfx/pics/mypic.png" then what DSB ends up actually looking for is "X:/DSB/Project/DSB/Project/gfx/pics/mypic.png" which will of course not be found.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ok so this makes more sense now thanks both.

I have made all the changes to the folder structure and to the path names. I made ‘progress’ in the sense that, when running DSB, it flagged a range of different ‘bitmap not found’ messages, which were all fixed mainly due to uppercase lowercase discrepancies in the graphics.cfg and the lua files. I need to refresh myself on the rules here for upper and lower usage.

However, once all these were corrected, I am now back to this first file it’s trying to load (the ‘sentinel’ bitmap) which happens to be the first entry called from the gfx_monsters.lua’, and its saying bitmap not found again.

I have checked and checked and still can’t see what the issue is. Unless, the path logic is still wrong somehow. But the path is consistent with what you recommend above, including forward slashes. And I’ve tried subbing the file to cross check it’s not just a corrupt file.

Will keep looking at this, but here’s the update!
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

As I said before, I've reached the limit of my ability to help without actually having the files.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Ok, all fixed and working! I had to change the text in the = dsb_get_bitmap in the gfx lua files to be capitals

Correct:

Code: Select all

gfx.BITMAP = dsb_get_bitmap("BITMAP")
Created errors:

Code: Select all

gfx.BITMAP = dsb_get_bitmap("bitmap")
Need to see why this is. But probably when I did an excel ‘get data from folder’ to process all the file names it copied through the actual file name text which is lowercase.
User avatar
Gambit37
Should eat more pies
Posts: 13769
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Gambit37 »

You have an image caled "BITMAP"? I'd recommend calling that something a bit more descriptive! :D

Also, it's infinitely more straightforward if every file name is in lowercase. Why do you need to use multi-case?
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

:lol: yeah ‘bitmap’ might be a little vague, granted

Why mix? Not sure. Probably because I thought I’d read on here somewhere to go for capitals. I think before changing over to the graphics config setup everything was caps, and in the excel bit I lost the consistency. But much more likely it’s because I’m not very good at coding…!

But thanks to you and Sophia for helping this noob out. :)
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

One thing I’ve noticed using the graphics.cfg method is:

I am using a custom dooorbutton.pcx bitmap to replace the standard ingame bitmap. Having an exact ‘replica’ or ‘impostor’ of this file is the only way I could find to use a visually different door button to sidestep the issues documented earlier in the thread where I was not able to use a custom door button graphic with different file name - the x and y offsets just didn’t work*.

So this workaround uses a stock ingame door button object on the doorframe, DSB calls the standard doorbutton.pcx from the base game bitmaps, but it then displays my ‘impostor’ customised bitmap doorbutton image. DSB is none the wiser. So while this limits me to only one alternative doorbutton.pcx visual, all good so far.

But, I’ve found that this impostor doorbutton.pcx technique requires the doorbutton.pcx to be located directly next to the dungeo.lua; this workaround won’t work if it’s located in the GFX folder location with all the other custom assets that the graphics.cfg calls to.

It’s not a big deal, but is there a way to make this work with the GFX folder location somehow?

(*The alternative solution was to draw a button on a doorframe graphic itself, and then have an invisible doorbutton.pcx bitmap, to not show the ingame button over the doorframe, but have it remain clickable)
kaypy
Artisan
Posts: 187
Joined: Sun Jan 19, 2014 7:11 am

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by kaypy »

Wouldnt you just put

gfx.doorbutton = dsb_get_bitmap("my_version_of_the_front_doorbutton_bitmap")
and
gfx.doorbutton_side = dsb_get_bitmap("my_version_of_the_side_doorbutton_bitmap")

in your gfx code?
Friends don't let friends eat worm round
kaypy
Artisan
Posts: 187
Joined: Sun Jan 19, 2014 7:11 am

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by kaypy »

Set
gfx.doorbutton.x_off = 0
gfx.doorbutton.y_off = 0
initially

Rig up a test dungeon with a door and button and take a screenshot standing in right front of it
Measure how far you need to move the button image up and across.

Set
gfx.doorbutton.y_off
to -(how far you need to move the button up)
except if your screenshot is in double size then the distances will need halving

Since x_off has issues, go back to your my_version_of_the_front_doorbutton_bitmap and give it a big empty left hand margin to push the button as far right as you need. The margin will need to be twice as large as your screenshot would indicate (cause centering) (but this will cancel out double size)

I was able to get a random test bitmap into the right button position without too much hassle that way
Friends don't let friends eat worm round
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Thank you. When I tried a custom bitmap, I found it wouldn't move from direct centre, or at least hard to reposition (need to go back and check) irrespective of any application of offsets. What I perhaps did not try, though, was keeping the name as 'doorbutton' - maybe this is what makes the difference.

I was using an approach like 'my_doorbutton_1' on the basis 1) just give the custom graphic a more descriptive title and 2)I was planning to have more than one custom button potentially.

I might need to recheck this again, also: viewtopic.php?t=31368
kaypy
Artisan
Posts: 187
Joined: Sun Jan 19, 2014 7:11 am

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by kaypy »

The doorbuttons use a custom draw method, you can see renderer_hack="DOORBUTTON" in the obj

I think part of that is ignoring the x offset

(But I'm guessing it also does a bunch of other stuff that you wont want to get rid of)
Friends don't let friends eat worm round
kaypy
Artisan
Posts: 187
Joined: Sun Jan 19, 2014 7:11 am

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by kaypy »

Hmm. Played around a bit more, and now it seems to be working for me x_off and all?

Code: Select all

gfx.doorbutton = dsb_get_bitmap("gfx/testbutton")
gfx.doorbutton.x_off = 120
gfx.doorbutton.y_off = -110
where gfx/testbutton.pcx is a 12x12px test file
Friends don't let friends eat worm round
User avatar
Gambit37
Should eat more pies
Posts: 13769
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Gambit37 »

The thing with doorbuttons is that they can float over foreground walls if the offsets are wrong. And some views don't show any buttons at all (I think one step left/right + two distant). I was fixing perspective problems with the wallset and doorframes, and discovered that by luck because my perspective changes needed to show buttons where DSB previously didn't render them.
(*The alternative solution was to draw a button on a doorframe graphic itself, and then have an invisible doorbutton.pcx bitmap, to not show the ingame button over the doorframe, but have it remain clickable)
This is what I ended up doing. It looks much better too due to all my pre-designed distance shading. I have a little lua function attached to the spawn method of the doorframe. It checks if there's also a button on the same tile, and if so it swaps out the doorframe for the one with the pre-drawn button on it. The button itself is just a transparent image, to enable user clicks.
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

This code worked for me:

Code: Select all

gfx.doorbutton = dsb_get_bitmap("NEW_DOORBUTTON", "custom_asset_location/new_doorbutton.png")
gfx.doorbutton.x_off = 120
gfx.doorbutton.y_off = -110

gfx.doorbutton_side = dsb_get_bitmap("NEW_DOORBUTTON", "custom_asset_location/new_doorbutton.png")
gfx.doorbutton_side.x_off = 84
gfx.doorbutton_side.y_off = -110
Changing the offsets also behaved as expected. I changed x_off and y_off to 0 and the button was centered down by the floor, so there was nothing wrong with x_off for me either.

You can't change offsets via graphics.cfg. If you want to adjust them you will have to load the image this way.

The main thing the "DOORBUTTON" renderer_hack does is suppresses the drawing of the doorbuttton when it's on the left side. This is the issue that was giving Gambit trouble before. The reason it works this way is that normally x offsets are mirrored on the left and right sides of the screen; this is normally what you want, but in the case of a doorbutton, it caused the doorbutton to be drawn on the left side of the doorframe. Since the DM perspective covers up the button from that angle the simplest solution was a hack to just not draw it.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Thanks Sophia/all. Will give another go.

I have a wallitem bitmap rendering question: Is there a way to suppress or hide a render of a bitmap? Let's say I have a wall item decoration - a crack, for example - and I don't want DSB to render it for it's far position. I only want to see it for normal side position, and then the mid position. Is this possible? Thank you :)
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

If I had my dungeon designer hat on rather than my engine programmer hat, what I would do was give it a far_y_tweak that put it outside of the viewport. I don't know if this will actually work, and I don't "officially" support this method, but it might be worth a try.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Haha I was thinking that was one technique, and another could be using an invisible far graphic, but I had thought they’d both be seen as a bit ‘hacky’ and ‘impure’…!
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

kaypy wrote: Fri Feb 07, 2025 11:30 am Set
gfx.doorbutton.x_off = 0
gfx.doorbutton.y_off = 0
initially

Rig up a test dungeon with a door and button and take a screenshot standing in right front of it
Measure how far you need to move the button image up and across.

Set
gfx.doorbutton.y_off
to -(how far you need to move the button up)
except if your screenshot is in double size then the distances will need halving

Since x_off has issues, go back to your my_version_of_the_front_doorbutton_bitmap and give it a big empty left hand margin to push the button as far right as you need. The margin will need to be twice as large as your screenshot would indicate (cause centering) (but this will cancel out double size)

I was able to get a random test bitmap into the right button position without too much hassle that way
I drove myself crazy yesterday as I had this wall item side bitmap appearing in game way too big. I was tearing my hair out trying to figure out what was wrong with it. The bitmap was big and offset adjustments seemed all out of control. Eventually it dawned on me… I had drawn the graphic over a DSB screen grab and because I’ve only recently switched to 2x mode, it was a 2x screen grab…. Facepalm. Quick 50% resize of the bitmap and all good… eventually.

I like your ‘take screenshot and measure pixels to correct position’ idea. I’ll use that concept. I need a better grasp on where the bitmaps origins and rules are, right now I just eyeball it and adjust, test, adjust, test.
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

On the pixels placement question, here's a quick test. 1) is a 2 x 2 pixel square (small but just visible in this image), and 2) is 100 x 100 pixel square:

Image

This seems to place the bitmaps from their top centre, at a common 0,0 coordinate, at approximately the upper quarter line.

From the side view (for a side1 object), using a 100 x 100 pixel square again, looks like DSB also places it from top centre of the bitmap, at towards the top quarter line of the side wall, relative to side wall tile, in the tile in front of player's tile:
Image

And then for offsets, -y is 'up', +y is 'down', -x is 'left', and +x is 'right' (if I remember correctly): this is x=50, y=50:
Image

Is that a correct interpretation as to how it all works?
User avatar
Sophia
Concise and Honest
Posts: 4306
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Sophia »

Yes, so far, so good.

The x offsets for perspective and side views are mirrored on the right side, which is normally what you want, because that way the object is positioned the same on both walls. (As mentioned above in the doorbutton discussion, it is not always what you want)
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

So further to walls and wall items, a couple of discussion points.

Use of RTCWM: I’ve been using this very useful app to punch out different wallsets for the different themes and areas for this dungeon project. I’ve noticed, though, that as brilliant as this little app is, the final output it produces creates a very slight blur to the final image. So when I compare wall front1 for example, source image vs image output from RTCWM, the RTCWM output lacks sharpness compared to the source image. And this is with the mipmap setting turned off.

So I’ll need to use manual edits to at least wallfront1 and the immediate side and side alt bitmaps by using these from source, not relying on output from RTCWM. No major issue (I think), however RTCWM also has a very minor scaling difference to the source image. (Big note, no disrespect to RTCWM author, your app is brilliant and this probably unlocked getting into dungeon creation for me entirely, so thank you a million times if you’re reading!)

Seams and corners: Related to this, seams between panels and thinking about doing ‘rough’ walls, like cave walls with slightly funny edges. I have started experimenting with the way the walls rendering works and how the masks work. And in particular, corners. This was an interesting read, which I think (stress think) I am following viewtopic.php?p=161014&hilit=Tall+walls#p161014 with Gambit and Sophia. Any tips or examples anyone could share here? Also there is talk over DM 2.x / 3.x graphics: what exactly does this mean?

Wallitems rendering question: is there a way to make a wallitem appear rendered on the Side0 on the player’s tile? It’d mean the wall item would likely be cropped slightly off the edge of the game viewport. Is this technically possible? I have some slightly wider wallitems (bigger alcoves, for example) that technically should appear in the players tile sidewall, but don’t, until you turn to face them. Appreciating this is exactly how the original DM worked.

Tall walls/no ceilings: I haven’t tried yet, but is this possible in DSB? If so, any pointers / examples as to how this works?


Thank you!
User avatar
Ser Xav
Lo Master
Posts: 449
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Tutorials: wallsets and custom monsters, objects, etc

Post by Ser Xav »

Also, meant to ask one more, regarding sounds: is it possible to to play a sound when I put an object into the inventory or pick it up? Is there any example code as to do this?
Post Reply