View Single Post
Old February 7, 2019, 05:32   #52
Nick
Vanilla maintainer
 
Nick's Avatar
 
Join Date: Apr 2007
Location: Canberra, Australia
Age: 54
Posts: 7,780
Donated: $60
Nick is on a distinguished road
I thought a brief history of the data files might be helpful here. I'll describe four stages, focusing on wands:
  1. 2.4.fk - in the beginning, there was a single .c file that handled wands, wands.c, calling it's effects from spells.c. Everything hard-coded, no mucking about.
  2. 2.8.3 - now we have a text file containing all the objects, k_info.txt, but it's not really very readable. In particular, note the "I" line, for example
    Code:
    I:65:18:0
    for wands of fire bolts. The 65 meant it was a wand, and the 18 meant fire bolts; the game looked these up in a big master list, defines.h, and then used the values as an index when it was producing the effect in the file which dealt with item use, cmd6.c.
  3. 3.2.0 - the text file, object.txt, is getting more readable. It still has a lot of coded fields, but they are explained at the top of the file, and our wand of fire bolts now has a line
    Code:
    E:FIRE_BOLT2
    to indicate that it uses the effect FIRE_BOLT2. The way the game does that is to look up that effect in effects.c, which codes that particular effect. Note that effects.c also has FIRE_BOLT, FIRE_BOLT3 and FIRE_BOLT72, which produce fire bolts for a rod or a spell or an activation, but with different parameters.
  4. current master - now object.txt has the lines
    Code:
    effect:BOLT_OR_BEAM:FIRE
    dice:12d8
    which tell the game to produce a bolt (or beam), make it of fire, and give it power 12d8. The bolt effect is in effects.c, but now in a function which takes its parameters from the object.txt file, rather than being hard-coded.

So gradually more and more data has made its way from being hard-coded in .c and .h files to being in the user-editable-without-recompiling data files. Which is best is a matter of opinion.
__________________
One for the Dark Lord on his dark throne
In the Land of Mordor where the Shadows lie.
Nick is online now   Reply With Quote