Creating new objects

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.
Post Reply
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Creating new objects

Post by ebeneezergude »

So am now getting into proper tinkering with DSB to assess if it's the way to go for my dungeon - and it's looking tempting as adding/changing graphics seems a doddle. Having read the tutorials, I am not quite sure I understand the relationship between duplicating an object arch type to create a new object, replacing it's btmaps graphics with a new custom bitmaps, and then giving it a new icon. The icongrid.pcx file - how does that work? Do I need to enlarge it to create a new icon for a new object? Or do I not need to use it, can I create a 'one off' icon graphic called by the new object code, and store that graphic somewhere? Where would that best be placed? Am essentially testing a fully new object based on say, a key. I want a new icon and a new bitmap. :? Thanks in advance!
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Creating new objects

Post by Sophia »

You don't need to add to the icongrid if you don't want to. It's certainly possible (and, as long as you're not adding a ton of new objects, easier!) to just use a single bitmap as an icon, like RTC does.

Here is a tutorial for adding custom objects (the second half of the post)
http://www.dungeon-master.com/forum/vie ... 53&t=28988
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Creating new objects

Post by ebeneezergude »

Thanks. OK, have now found some useful info in the graphics.lua and the dsb pages on dungeon master wiki (wow... didn't know these existed!). So icon grid number seems to be determined by the number of pxiels along a 16 column, 32x32 pixel-tiled file - ie 512 in width. Can this bitmap be extended vertically, arbitrarily by 32 pixels at a time? Is that what you mean by "it's certainly possible"? Can I keep adding 32 pixels to the vertical pixel dimension?

Still can't quite work out how to reference an individual bitmap for one icon only... but will keep digging!

EDIT: I guess I need to know what to write for Icon =
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Creating new objects

Post by ebeneezergude »

Actually, have managed it. I've created a test object of the consumable type with separate object and icon bitmaps.

Here's my graphics.lua file:

gfx.test_object = dsb_get_bitmap("test_object")
gfx.test_object_full = dsb_get_bitmap("test_object_full")

...first line is the bitmap for the icon, second line is the bitmap for the 'full' bitmap of the object in the viewport.

Here's my objects.lua:

Code: Select all

obj.test_object = {
	name="TEST OBJECT",
	type="THING",
	shortdesc="CONSUMABLE",
	class="FOOD",
	mass=4,
	icon=gfx.test_object,
	dungeon=gfx.test_object_full,
	foodval=500,
	fit_pouch = true,		
	on_consume=eatdrink
}
...where I've made a consumable test object (based on an apple).

So, both object and icon work....phew...!
Last edited by ebeneezergude on Sun Feb 03, 2013 9:10 pm, edited 1 time in total.
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Creating new objects

Post by ebeneezergude »

OK, so my next question then - where in the bitmap does it register the 'base' of the bitmap in terms of co-ordinates? The apple.pcx happens to have the apple pixels drawn at the very base of the bitmap. The brickswitch_front.pcx bitmap has the switch pixels drawn at the very top of the bitmap. Button_green_front.pcx has the button pixels drawn in the middle of the bitmap (surrounded by 'powerpink').

If I put the button_green_front.pcx onto an apple object, it would therefore appear to be floating above the floor. How do I know or define what the reference point is for any given bitmap? Ie, where is it's base, or it's centre?

Thanks!
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Creating new objects

Post by Sophia »

If you're going to paste code, please put it in a block. It makes it much easier to read. :)

ebeneezergude wrote:OK, so my next question then - where in the bitmap does it register the 'base' of the bitmap in terms of co-ordinates? The apple.pcx happens to have the apple pixels drawn at the very base of the bitmap. The brickswitch_front.pcx bitmap has the switch pixels drawn at the very top of the bitmap. Button_green_front.pcx has the button pixels drawn in the middle of the bitmap (surrounded by 'powerpink').
DSB tries to "just work" with respect to bitmap positioning. The "reference point" for each type of object is slightly different, due to the different positioning that is considered important for each object. So, you're correct, wallitems and doors are positioned according to their absolute center, while items resting on the floor are positioned according to the center of their bottom row. However, this determination is done by object type.
ebeneezergude wrote:If I put the button_green_front.pcx onto an apple object, it would therefore appear to be floating above the floor. How do I know or define what the reference point is for any given bitmap?
That means this statement isn't true. The button will be placed like any other thing resting on the floor.

It isn't that you define an absolute position for a bitmap and then the engine always draws it there. :)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Creating new objects

Post by Gambit37 »

This is what I meant when I said bitmaps in DSB "just work". Most stuff is positioned automatically and you don't need to worry about working out offsets. It's great :-) You can make micro adjustments using various offset properties in the archetype.
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Creating new objects

Post by ebeneezergude »

I'm starting to see where you're coming from, Gambit ;-)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Creating new objects

Post by Gambit37 »

I started some pages about objects/archetypes on the DSB Wiki, you might find them useful, although they are still very incomplete:

http://dmwiki.atomas.com/wiki/DSB/Archetypes
http://dmwiki.atomas.com/wiki/DSB/Archetypes/Properties
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Creating new objects

Post by ebeneezergude »

Gambit, thanks for the links to your wiki pages, very useful reading.

Sofia, did you have any joy on getting individual icons into ESB? Could it be achieved by implementing a new line of code within an object entry, similar to the one calling in a bespoke bitmap? Ie, something along the lines of:

Code: Select all

 
icon_ESB=gfx.new_object_editor_icon
...thus bypassing the cells.pcx and directly referencing a graphic into the editor. I'm sure it's not as simple as I have made it out to be, but you get the idea! :-)
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Creating new objects

Post by Sophia »

Yes, that's actually more or less the approach I'd take.

I just haven't gotten around to it yet. It was a somewhat busy week. :)
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Creating new objects

Post by ebeneezergude »

Hi Sophia, it certainly was...! Thanks. Presumably the code could also be written with the option to point to a custom cells.pcx?
User avatar
ebeneezergude
Expert
Posts: 345
Joined: Mon Jan 21, 2013 10:58 pm
Location: I see walls stretching off into the darkness...

Re: Creating new objects

Post by ebeneezergude »

How does DSB deal with hidden statistics? Ie, the rabbit foot object from DM. Is Apply_Luck a fixed value? Can you control the value? What other hidden stats are accessible?

Code: Select all

obj.rabbits_foot = {
	name="RABBIT'S FOOT",
	type="THING",
	class="MISC",
	mass=1,
	icon=gfx.icons[137],
	dungeon=gfx.rabbits_foot,
	max_throw_power=40,
	to_anywhere=apply_luck,
	from_anywhere=remove_luck,
	fit_pouch=true,
	go_thru_bars=true

Thanks!
User avatar
Sophia
Concise and Honest
Posts: 4239
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Creating new objects

Post by Sophia »

The only hidden stat supported by DSB by default is Luck, but you can add your own stats and other information through the use of character exvars (the ch_exvar table).

You can change the value used by apply_luck simply by editing the function itself. It's in base/util.lua, and it also demonstrates the use of ch_exvar.
Post Reply