data dirs renamed
[k8-i-v-a-n.git] / Doc / script_course / lecture5.html
blobab80201892652c78c0fced8caaa3017b7d87c7f3
1 <html>
2 <head>
3 <title>IVAN script lecture 5</title>
4 </head>
5 <body>
7 <h2>holybanana's IVAN script course, lecture V</h2>
8 <h4>Adding materials</h4>
10 <p>This lecture is a bit more like a reference guide than a lesson.
11 You don't need to know everything in it. In practice, you should first
12 choose a material which is very close to your material, copypaste its
13 data and modify it. If you want to know what some value does, or you
14 need to know whether there is a database value which does the thing
15 you want, then you consult this guide.</p>
17 <p>When adding materials, you first choose the type, as always.
18 The hard-coded types are</p>
20 <p>
21 <b>solid</b>: No special properties.<br>
22 <b>organic</b>: Spoils eventually.<br>
23 <b>gas</b>: Can appear over a square as a cloud of smoke.<br>
24 <b>liquid</b>: Can be spilled on items or squares.<br>
25 <b>flesh</b>: Spoils eventually, can have colored skin, can have leprosy.<br>
26 <b>powder</b>: Can become wet.<br>
27 <b>ironalloy</b>: Can rust.
28 </p>
30 <p>What does "can have colored skin" mean? If a limb is made
31 of some material other than flesh, its color is that material's
32 color, but for flesh it may be overridden by the SkinColor database
33 member of character databases, even though the material is blood
34 red from the inside.</p>
36 <p>After choosing the appropriate type, you choose a new config,
37 for instance CUSTOM_MATERIAL. Note that you write it with BIG_LETTERS,
38 using '_' in place of space. Suppose you chose to add an organic
39 material. You look into define.dat and find the following lines:</p>
41 <pre>
42 #define ORGANIC_ID (4096 * 2)
44 #define BANANA_FLESH (ORGANIC_ID + 1)
45 #define SCHOOL_FOOD (ORGANIC_ID + 2)
46 ...
47 #define OMMEL_BONE (ORGANIC_ID + 13)
48 #define OMMEL_TOOTH (ORGANIC_ID + 14)
49 </pre>
51 <p>You just add
53 <pre>
54 #define CUSTOM_MATERIAL (ORGANIC_ID + 15)
55 </pre>
57 <p>here and start making the config in material.dat, after the
58 old organic configs, like explained in <a href="lecture1.html">lecture I</a>.</p>
60 <p>Materials have five database values which consist of a number
61 of flags which are either on or off. These are CommonFlags, NameFlags, CategoryFlags,
62 BodyFlags and InteractionFlags. By default, the flags of a material
63 are the flags of the database which is its base, for instance
64 for a flesh material the flags of flesh. If you want to set a flag on,
65 you use the command Flags = Base|Flag; and if you want to set
66 it off, you use the command Flags = Base&~Flag; Here Flags is
67 one of the flag members above. This
68 syntax may seem odd for those who are not C/C++ programmers, but
69 those with knowledge of bitwise operations | (<i>or</i>), &
70 (<i>and</i>) and ~ (<i>not</i>) immediately notice that
71 this is similar to the basic C/C++ syntax.</p>
73 <p>We will now list all the flags for materials. CommonFlags are</p>
75 <p>
76 <b>CAN_BE_WISHED</b>: If the material can be summoned with a scroll of change material.<br>
77 <b>IS_VALUABLE</b>: If this is set, pets avoid consuming this and leave it for you.<br>
78 <b>CAN_BE_MIRRORED</b>: If you can mirror an item made of this material.
79 </p>
81 <p>NameFlags are</p>
82 <b>USE_AN</b>: Whether you use "an" instead of "a" as the article of the material's name.
83 <p>
85 </p>
87 <p>CategoryFlags are</p>
89 <p>
90 <b>IS_METAL</b>: Can be fixed by a smith.<br>
91 <b>IS_BLOOD</b>: Affects descriptions of items and squares covered with this liquid.<br>
92 <b>CAN_BE_TAILORED</b>: Can be fixed by a tailor.<br>
93 <b>IS_SPARKLING</b>: Sparkle animation is generated for objects made of this material.<br>
94 <b>IS_SCARY</b>: Monsters avoid this kind of smoke.<br>
95 <b>IS_GOLEM_MATERIAL</b>: Golems made of this material are generated.
96 </p>
98 <p>BodyFlags are</p>
101 <b>IS_ALIVE</b>: Affects bodyparts made of this material in various ways, for instance whether it bleeds. Only characters with an alive torso can be poisoned or drained from life, etc.<br>
102 <b>IS_WARM</b>: A creature can be seen by infravision if it has a bodypart whose material is contains warm blood.<br>
103 <b>CAN_HAVE_PARASITE</b>: Can contain a parasite if spoiling.<br>
104 <b>USE_MATERIAL_ATTRIBUTES</b>: If this is not on, a bodypart's physical attributes (Strength, HP, etc.) are initialized based on the character's database and the bodypart can gain exp. Otherwise they depend on the material's StrengthValue and Flexibility.<br>
105 <b>CAN_REGENERATE</b>: Whether the bodypart can regenerate lost HPs.
106 </p>
108 <p>InteractionFlags are</p>
111 <b>CAN_BURN</b>: Only books and scrolls made of burnable materials are destroyed by explosions.<br>
112 <b>CAN_EXPLODE</b>: Containers containing this material can explode.<br>
113 <b>CAN_DISSOLVE</b>: Is affected by acid.<br>
114 <b>AFFECT_INSIDE</b>: When consumed, the liquid doesn't affect immediately, but is left in the body, affecting your throat and stomach until it vanishes. Used for acids currently.<br>
115 <b>EFFECT_IS_GOOD</b>: Pet's are not enraged if you throw containers, for instance potions, full of this material at them.
116 </p>
118 <p>Here's a full list of material database values. int means that the
119 type of the value is an integer. I have marked the obligatory ones
120 with an asterisk (*). These you must define every time you make
121 a new material.</p>
123 <b>int StrengthValue (*)</b>: One of the most important attributes. Affects how much damage items made of the material do and
124 how much they resist damage before breaking. Determines the strength and HP of a bodypart made of this material if
125 the USE_MATERIAL_ATTRIBUTES flag is set.<br>
126 <b>int ConsumeType</b>: You can find the consume types in define.dat. They are named starting with CT_, for instance CT_METAL. This affects whether monsters can consume items made of this material.<br>
127 <b>int Density (*)</b>: The density in grams per litre.<br>
128 <b>int Color (*)</b>: This should be a 16-bit color, eg. rgb(150,100,100). Affects outlook.<br>
129 <b>int RainColor</b>: This is only used when the material is raining from the sky.<br>
130 <b>int PriceModifier</b>: The value of a lump of this material is determined by this.<br>
131 <b>int Emitation</b>: This should be a 24-bit color, eg. rgb24(135, 155, 135). This determines the color and strength of light emitated by the material.<br>
132 <b>int NutritionValue</b>: How quickly a character consuming this material becomes satiated.<br>
133 <b>string NameStem (*)</b>: The basic name of the material.<br>
134 <b>string AdjectiveStem</b>: The adjective form of the material's name, eg. "golden" for "gold". Defaults to NameStem.<br>
135 <b>int Effect</b>: The effect which is run when the material enters the body of a creature. You can find all the effects in define.dat. They start with EFFECT_, for instance EFFECT_HEAL.<br>
136 <b>int ConsumeEndMessage</b>: Index of msg which is printed when consuming this stuff has ended. They start with CEM_ in define.dat.<br>
137 <b>int HitMessage</b>: Index of msg which is printed when consuming this stuff has ended. They start with HM_ in define.dat.<br>
138 <b>int ExplosivePower</b>: Only affects if the CAN_EXPLODE flag is set.<br>
139 <b>int Alpha</b>: Determines the transparency of the material. 255 means fully opaque, 0 means invisible.<br>
140 <b>int Flexibility (*)</b>: A very important attribute, too. Tells how much agility or dexterity penalty an armour made of this material causes. Also determines the dexterity or agility of limbs made of this material.<br>
141 <b>int SpoilModifier</b>: How slowly the material spoils. Only affects organic and flesh materials.<br>
142 <b>int EffectStrength</b>: How strong the effect of the Effect value is.<br>
143 <b>int DigProductMaterial</b>: Which material is created when a wall made of this material is destroyed.<br>
144 <b>int ConsumeWisdomLimit</b>: Monsters which have this or higher intelligence don't consume this material. Default is NO_LIMIT.<br>
145 <b>int AttachedGod (*)</b>: Affects offering and whether a god can make a bodypart of this material. You can check the gods from define.dat. For instance VALPURUS.<br>
146 <b>string BreatheMessage</b>: A string which is printed if one enters a square which has a cloud of smoke made of this material over it.<br>
147 <b>int StepInWisdomLimit</b>: Monsters which have this or higher intelligence don't step in a cloud of this material, unless they have to. Default is NO_LIMIT.<br>
148 <b>int RustModifier</b>: For ironalloys, how quickly the material itself rusts. For liquids, how quickly the material causes rust on ironalloys.<br>
149 <b>int Acidicity</b>: How powerful acid this material is, or 0 if it's neutral.<br>
150 <b>item contentscript NaturalForm</b>: The item which is created when a terrain made of this material is destroyed. Also used in several other occasions, for instance when a golem is destroyed.<br>
151 <b>int HardenedMaterial</b>: Which material this material hardens to. Please choose a material with the same AttachedGod.<br>
152 <b>int IntelligenceRequirement</b>: The intelligence requirement of hardening another material to this material. Summoning a material requires this +5 int.<br>
153 <b>int Stickiness</b>: How sticky the material is if you are stuck to it.
154 </p>
156 <p>Exercise: Create an ommel nut flesh material, which spoils slowly and radiates bright yellow light. Make it so that golems can be generated of this material but it cannot be wished nor mirrored. It belongs to Nefas. Let it have the same effect and messages as ommel urine, but the effect is stronger. Let its natural form be a nut. Present the config definition.</p>
158 <hr>
161 <a href="lecture4.html">Previous lecture</a>
162 <a href="index.html">Back to main</a>
163 </p>
165 <hr>
167 <p>Last modified September 6 2006.</p>
169 </body>
170 </html>