Modifying magic system / SYS_ message black boxes?

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
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Modifying magic system / SYS_ message black boxes?

Post by Gambit37 »

I'm looking at doing something a little different with Magic. I was looking at the possibility of doing a Grimrock style grid, where you select all the runes of the spell in one go, rather than DM's tiers.
http://www.crimsontear.com/gaming/legen ... ock/spells

So I want to understand what happens as a result of this line:

Code: Select all

dsb_msgzone(bmp, SYSTEM, 5, 2, 42, 140, 22,SYS_MAGIC_CAST, sel_ppos, 0)
I understand the coordinates, etc, but what happens as a result of SYS_MAGIC_CAST? (And similarly other SYS_ messages) Presumably the code for managing all this is hidden in the core engine's black box, which makes it hard to really understand what's going on, and how I might modify it. Is there a tutorial for how to modify this sort of thing?

A couple of other confusing things:

1) Documentation says dsb_msgzone() is only used in subrenderers but this is clearly not the case -- they are used in all the interface elements drawn to the right of the viewport. Perhaps "subrenderer" needs to be more clearly defined?
http://dmwiki.atomas.com/wiki/DSB/Subrenderers

2) What's the extra 2 parameters on dsb_msgzone()? The wiki lists 8, but there's 10 in all the code examples I've found.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Modifying SYS_ message black boxes?

Post by Sophia »

I've updated the wiki pages to hopefully be more helpful on all of these questions.

http://dmwiki.atomas.com/wiki/DSB/Messages
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Modifying SYS_ message black boxes?

Post by Gambit37 »

Aaaaaha! Cool :-) Somehow I had totally missed sys_spell_cast(), I thought it was all locked away in the EXE.
I feel some major tinkering coming on.....
Thanks :-)
User avatar
Gambit37
Should eat more pies
Posts: 13714
Joined: Wed May 31, 2000 1:57 pm
Location: Location, Location
Contact:

Re: Modifying SYS_ message black boxes?

Post by Gambit37 »

Have looked at the magic spells code.... I think I can do something more like Grimrock, but to do so I need a single grid of runes where each rune can be selected arbitrarily in any order. I think can see how I can make that work (Rune sets = 1, runes per set = 16)

However, this means I can't use simple numbers to represent the runes that build spells, as I have more than 9 runes in my grid. However, the spell identifiers seem to be simply named keys in the spell array, so presumably I could use letters instead, such as [AGKL] ? I know I'd need to rewrite all the code to manage that, but I think I can see what I'd need to do.

I'm quite excited about getting this to work. I think it'll be the first time anyone has made a new magic system using a DM clone engine :-) The great thing about this approach is that the runes will be logical and literal so it should be easy for players to work out new basic spells (
Spoiler
Air + Fire = Fireball for example
), so you wouldn't even need a tutorial or any background info in the game. Of course, more esoteric spells will still need to be revealed in the gameplay, on scrolls, etc.

I'm also interested in using magic in a sort of alchemy system, so that creating and managing resources becomes part of gameplay too. For example:
Spoiler
Find and hold some sand and cast "Fire": this creates a lump of glass. Adding an extra rune (eg "Craft") could craft that glass into a flask for potions.
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: Modifying SYS_ message black boxes?

Post by Sophia »

Gambit37 wrote:However, this means I can't use simple numbers to represent the runes that build spells, as I have more than 9 runes in my grid. However, the spell identifiers seem to be simply named keys in the spell array, so presumably I could use letters instead, such as [AGKL] ?
Another option (requiring less modification of code) would be to simply introduce a separator, and use string concatenation rather than addition. So for example an entry in the spell table would be "1_10_6" or something like that.

I'll also point out that both letters and anything involving underscores will no longer be a number (and, as such, handled like a string) so there's no change in the way you process them. In case that's not clear, a brief review of Lua syntax: number keys to an array can be specified like array[100]. A string key has to be specified as either array.stringkey or array["stringkey"], i.e., either with a dot or quotes. Writing something like array[AGKL] won't work the way you probably expect because Lua will not look for a key named "AGKL", it will look for a key stored in a variable called AGKL.
Post Reply