KhymChanur: For 3.0.0, traps are internally registered as spells so it will be possible for players to create traps from the spells they can cast, right? If that's the only reason, then I propse that we now separate out the trap internals from the spell internals. While working on the trapping code, I've made it so that, when a trap is activated, that the flagset making up the trap will be available to the trap's activation code, and thus the activation code can make use of arbitrary data contained in the flagset. To make a player-set spell-based trap, you'd set FLAG_TRAP_IDX to the spell-based trap, then add FLAG_SPELL_IDX to the flagset so the spell-based trap activation code can find the spell to cast.
I'm not proposing this for reasons of efficiency or desire to add some new feature, but rather for keeping a clean design. Having traps internally be a type of spell is rather hackish, and I'd prefer to avoid such hackish-ness unless it's absoultely necessary.
NeilStevens: I proposed having every trap *effect* be a spell, which makes perfect sense to me because that's what traps are, really.. How is that different from what is done now?
KhymChanur: That is how it's being done now, yes. However, just because the effects of tripping a trap are pretty much the same as a spell doesn't mean the code and data structures should necessarily be shared. Sharing code and data structures with spells means that some trap related info needs to be passed around as global variables, which should be avoided if possible. If traps re-used spell features like failure rate, mana/piety cost, what skills are needed for casting, and so on, then I could see having traps internally being a type of spell; however, as of now, all that is done is that auto_cast() is called to set things up, the spell function is invoked, and auto_cast is then unset .
KhymChanur: Proposal accepted by DarkGod in an email:
I kinda agree .. Well if you can make the traps easier to understand and work with while retaining the possibility to bind spells, go for it.
ToME Wiki