Debian Codegraph @

doc/Developers/objects

raw
1
2
3 This so far only concerns how to make archetypes, treasure and NPC's
4
5 Sections:
6
7 1. How to create new Archetypes and Bitmaps
8
9 2 Things that are alive (monsters, npcs)
10 A. Attack Types (attacktytpe)
11 B. Immunity (immune) (protected) (vulnerable)
12 C. NPC Movement (attack_movement)
13 D. Picking up other items (pick_up)
14 E. Using other objects (will_apply)
15 F. Treasure lists (randomitems)
16 G. Usage of certain flags for monsters
17 H. Generators
18 I. NPC's and their life - behaviours
19 J. NPC's Speak out - messages
20
21 3. Objects in general
22 A. Names (name, name_pl)
23 B. Types (type) & Subtypes (subtype)
24 C. Client Types (client_type)
25 D. Animations (anim - mina) (facings)
26 E. Material types (material)
27 F. Item Power (item_power)
28 G. Body Location
29 H. Meaning of certain attributes for certain items:
30 I. Lore
31 J. Movement types
32
33 4. SPECIAL OBJECTS
34
35 A. MAPS
36 B. HOLY_ALTARS
37 C. DISEASES
38 D. CONVERTERS
39 E. BOWS & ARROWS -missile weapons
40 F. Creators -object creating objects
41 G. Player Movers
42 H. Directors
43 I. Magical Walls -walls that cast spells
44 J. Containers
45 K. Mood Floors
46 L. Altars, Triggers, Detectors and other connected items
47 M. Signs
48 N. POISONOUS BOOZ
49 O. Duplicators
50 P. Transports
51 Q. Dragon Focus
52 R. Races & Classes
53
54 5. Flags & specifications for objects
55
56 6. TREASURES
57
58 7. Misc change description
59
60 8. How to Add new values
61
62 9. Programming notes
63
64 *******************************************************************************
65 1. HOW TO CREATE NEW ARCHETYPES AND BITMAPS:
66 ********************************************************************************
67 0) Determine if a new archetype is really needed. Archetypes are only needed
68 to add new images, or if the archetype simplifies creation of a very common
69 item. Don't make a new arch if all you really need to simply customize an
70 existing archetype.
71 1) Figure out which directory/category the object will belong to. This
72 determines an appropriate location for it inside the 'arch' directory. For
73 objects with many animations or that are very large, a new subdirectory may
74 be advisable.
75 2) Create a bitmap. It must be divisible by 32 in both height and width. The
76 file format should be .PNG 256 colour with transparency.
77 3) Create additional bitmaps if you want animation or directional facing.
78 4) Split the bitmaps up into 32x32 bitmaps and named according to the
79 naming.doc conventions in the arch tar package. Note, this is not really
80 necessary at current time - non-split images should work properly, but some
81 older clients may have problems with it. (the script "splitxbm" may be
82 used and is included below).
83 5) Create an archetype entry. The file should be called object.arc, where
84 object is whatever the new object is. This is by far the most complicated
85 step. See "crossfire.doc" for an introduction on how to create archetypes.
86 Look at other similar archetypes to see how they have been made. If a
87 single 32x32 bitmap is created, only need one archetype is needed, but if a
88 larger bitmap is made which is cut down to several 32x32 bitmaps, use
89 "linked" archetypes are needed. To create a linked archetype, add a 'More'
90 line filed by the next piece. The X and Y coordinates in this next piece
91 determine the offset from the head (first) object. When making multipart
92 objects, they should be rectangular. Non rectangular may work, but has not
93 been tested.
94
95 Note that for multi-part objects, in most cases, only the values in the
96 head portion are used (eg, hp, damage, etc for monsters) so it is generally
97 unnecessary to put a copy of all the head tags in the other parts.
98
99 See the section later in this document about animations.
100
101 6) If the archetype is a creature or NPC, and if it has abilities such as
102 firebreathing or magical attacks, these abilities are put into the
103 treasures file in the appropriate entry, and as invisible objects. This is
104 also how inventory like bows or swords is given. Look at the other entries
105 in the treasures file for the format to use. Note that if an existing
106 entry in the treasures file does what you want, reuse it for the new
107 archetype. There is no requirement that each archetype have a unique
108 treasure list.
109
110 ------------------------------------------------------------------------------
111 What is an archetype and what is an object?
112
113 Objects are directly derived from archetypes. Everything the player
114 sees in the game is an object. The player never deals with archetypes.
115
116 Archetypes are the master objects. All objects have an archetype that they
117 are derived from. When an object is created, the archetype is used for
118 all the default values in the object. When an object is saved, the code
119 looks at the differences between the archetype and the object it is saving,
120 and only changes the different values.
121
122 Archetypes are the entries in the 'arch' directory. The fields for
123 archetypes and objects are generally the same.
124
125 Note that by using this archetype model, it means an archetype can get
126 updated and all objects that are derived from it will get updated -
127 this is very useful when new fields are added - the archetypes can get
128 updated, and all objects in maps, player save files, wherever, get
129 this new value.
130
131 It is valid to put items into an archetype, including a customized version. All
132 objects created from the archetype will include the object(s) (including their
133 own inventory).
134
135 *******************************************************************************
136 2. Things that are alive
137 *******************************************************************************
138
139 The name in parentheses after a flag description is the name as it should be
140 used in the archetype file. For example: Attack type (attacktype)
141
142
143 A. Attack Types (attacktype)
144 ===============
145
146
147 Attack types bit description
148
149 Physical 1 Basic attacktype.
150 Magic 2 All magic spells, but not prayers
151 Fire 4 Can ignite objects
152 Electricity 8 Can also ignite objects
153 Cold 16 Can freeze objects into ice cubes
154 Confusion 32 Movement/attack directions become random
155 Acid 64 Random equipped item gets -1 to magic attribute
156 Drain 128 Victim loses 2% exp, attacker gains half of that
157 Weaponmagic 256 Direct damage: Special, use with care
158 Ghosthit 512 Attacker dissolves (obsolete)
159 Poison 1024 Some damage each turn thereafter
160 Slow 2048 Speed is reduced
161 Paralyze 4096 Speed is reduced to zero
162 Turn undead 8192 Like Fear, but for undead only
163 Fear 16384 Like Turn Undead, but for living only
164 Cancellation 32768 Removes magic (+/-) from items
165 Depletion 65536 Lose one point from one stat (can be restored)
166 Death 131072 Chance of instant death, otherwise nothing
167 Chaos 262144 None by itself, uses random other types
168 Counterspell 524288 Cancels magic spells
169 Godpower 1048576 Adds relevant god's attacktype
170 Holy Word 2097152 Enemies: X5, Undead: X1 -unless friends, others: none
171 Blind 4194304 Blinds victim
172
173 Note that one archetype can have multiple attack types by adding
174 these values together. Thus, something with an attacktype of 65
175 would attack with both acid and physical.
176
177 B. Resistances
178 ===========
179
180 Creatures can have various resistances. If a creature has a resistance
181 value for a particular attacktype of 100, it is said to be immune
182 to that attacktype. The amount of resistance directly reduces
183 damage. A creature that has 25% resistance to fire only takes 75%
184 of the damage. A creature 99% resistant only takes 1% of the damage.
185
186 A few notes: If a creature/object is immune to magic, then it will be
187 immune to all damage from that attack, even if that attack type contains
188 more than just magic.
189
190 Otherwise, a creature needs to be immune to all attack types in order
191 to take no damage (thus, a creature that is immune to physical, but
192 getting hit by a weapon that does physical and fire would take normal
193 damage). The attack code goes through all the attacktypes, and
194 calculates the damage that each will cause. It uses the highest damage
195 total that any of these attacktypes will use.
196
197 For attacktypes that don't deal physical damage but instead effect
198 the creature in some way (drain, slow, paralyze, etc), the resistance
199 in general reduces the effect (duration, amount drained, etc).
200
201 C. NPC Movement (attack_movement)
202 ===============
203
204 Set the variable attack_movement to one of the below (cut from define.h):
205 /******************************************************************************/
206 /* Monster Movements added by [email protected] */
207 /******************************************************************************/
208 /* if your monsters start acting wierd, mail me */
209 /******************************************************************************/
210 /* the following definitions are for the attack_movement variable in monsters */
211 /* if the attack_variable movement is left out of the monster archetype, or is*/
212 /* set to zero */
213 /* the standard mode of movement from previous versions of crossfire will be */
214 /* used. the upper four bits of movement data are not in effect when the monst*/
215 /* er has an enemy. these should only be used for non aggressive monsters. */
216 /* to program a monsters movement add the attack movement numbers to the movem*/
217 /* ment numbers example a monster that moves in a circle until attacked and */
218 /* then attacks from a distance: */
219 /* CIRCLE1 = 32 */
220 /* + DISTATT = 1 */
221 /* ------------------- */
222 /* attack_movement = 33 */
223 /******************************************************************************/
224 #define DISTATT 1 /* move toward a player if far, but mantain some space, */
225 /* attack from a distance - good for missile users only */
226 #define RUNATT 2 /* run but attack if player catches up to object */
227 #define HITRUN 3 /* run to then hit player then run away cyclicly */
228 #define WAITATT 4 /* wait for player to approach then hit, move if hit */
229 #define RUSH 5 /* Rush toward player blindly, similar to dumb monster */
230 #define ALLRUN 6 /* always run never attack good for sim. of weak player */
231 #define DISTHIT 7 /* attack from a distance if hit as recommended by Frank */
232 #define WAIT2 8 /* monster does not try to move towards player if far */
233 /* maintains comfortable distance */
234 #define PETMOVE 16 /* if the upper four bits of attack_movement */
235 /* are set to this number, the monster follows a player */
236 /* until the owner calls it back or off */
237 /* player followed denoted by 0b->owner */
238 /* the monster will try to attack whatever the player is */
239 /* attacking, and will continue to do so until the owner */
240 /* calls off the monster - a key command will be */
241 /* inserted to do so */
242 #define CIRCLE1 32 /* if the upper four bits of attack_movement */
243 /* are set to this number, the monster will move in a */
244 /* circle until it is attacked, or the enemy field is */
245 /* set, this is good for non-aggressive monsters and NPC */
246 #define CIRCLE2 48 /* same as above but a larger circle is used */
247 #define PACEH 64 /* The Monster will pace back and forth until attacked */
248 /* this is HORIZONTAL movement */
249 #define PACEH2 80 /* the monster will pace as above but the length of the */
250 /* pace area is longer and the monster stops before */
251 /* changing directions */
252 /* this is HORIZONTAL movement */
253 #define RANDO 96 /* the monster will go in a random direction until */
254 /* it is stopped by an obstacle, then it chooses another */
255 /* direction. */
256 #define RANDO2 112 /* constantly move in a different random direction */
257 #define PACEV 128 /* The Monster will pace back and forth until attacked */
258 /* this is VERTICAL movement */
259 #define PACEV2 144 /* the monster will pace as above but the length of the */
260 /* pace area is longer and the monster stops before */
261 /* changing directions */
262 /* this is VERTICAL movement */
263 #define LO4 15 /* bitmasks for upper and lower 4 bits from 8 bit fields */
264 #define HI4 240
265
266
267 D.Picking up other items (pick_up)
268 ========================
269
270 Pick Up specifiers (defined with pick_up)
271
272 Nothing 1
273 Wealth 2
274 Food 4
275 Weapon 8
276 Armour 16
277 All but those defined 32
278 All 64
279
280 Note also that if can_use_armor, can_use_weapon, can_use_ring,
281 can_use_range, can_cast_spell, can_use_bow are set, then the creature
282 will pick up the matching items even if the pick_up element is not
283 set to pick up those items. Note that if all flags are unset the monster will
284 not pick up anything regardless of can_xxx flags.
285
286 This only applies to monsters. The player pickup method is much different.
287
288
289 E. Using other objects (will_apply)
290 ======================
291
292 specifiers will apply this
293 1 Handles
294 2 Treasure (chests)
295 4 Earthwall (tear down)
296 8 Door (open) */
297
298
299 F. Treasure lists (randomitems)
300 =================
301
302 This determines what treasurelist to use for generating the objects
303 treasures. For archetypes, the default is none, but for other objects
304 (like those loaded in maps), it will use the same treasure list as
305 the archetype it descends from unless otherwise specified. In the case
306 of objects, "none" can be be used to make no items generated.
307
308 The format of treasurelists is detailed further down in this file.
309
310 Treasure lists are also used to give spell and skill abilities to creatures.
311
312
313
314 G. Monster Flag Usage
315 =====================
316
317 Damage (dam)
318 ======
319 Damage determines the amount of damage the creature does. The form this
320 damage takes it determined by the attacktype the creature has.
321
322 When determining damage, a number between 1 and the damage value is
323 rolled. Thus, even if you have a +6 damage bonus from strength, magic
324 weapons, etc, a value of 1 could still be generated. Thus, even with very
325 high magical monsters or very high strength monsters, a low damage roll can
326 result some of the time.
327
328 Speed (speed)
329 =====
330 Speed. A speed of 1.0 means it acts every tick, a speed of 0.1
331 means it acts every 10 ticks.
332
333 level (level)
334 =====
335
336 Int (int)
337 ===
338 gives monsters a modifying to find hidden/invisible creatures.
339
340 Pow (pow)
341 ===
342 If the creature can cast spells, this is how many spell points
343 are regenerated each move.
344
345 Con (con)
346 ===
347 Monsters regenerate this many hit points each move. This is each
348 time the monster has a move (some for Pow). So two monsters with the
349 same Con can regenerate at different rates if their speeds are different.
350
351 Wis (wis)
352 ===
353 Determines how close a player needs to be before the creature wakes
354 up. This is done as a square, for reasons of speed. Thus, if the wisdom is
355 11, any player that moves within the 11x11 square of the monster will wake
356 the monster up. If the player has stealth, the size of this square is
357 reduced in half plus 1.
358
359 Spell points (sp)
360 ============
361 Number of spell points monster starts with
362
363 maxsp (maxsp)
364 =====
365 Maximum spellpoints for monsters
366
367 flying (flying)
368 ======
369 set flying to 1 if this can fly.
370
371 See Invisible (see_invisible)
372 =============
373
374 See in the dark (can_see_in_dark)
375 ===============
376
377 Spell reflection (reflect_spell)
378 ================
379 Very powerful, use carefully
380
381 Pass through (can_pass_thru)
382 ============
383
384 Kamikaze attacks (one_hit)
385 ================
386 Creatures with this value set to 1 will dissipate when they attack (like
387 ghosts). They dissipate on the first hit, whether it does any damage or not.
388
389 Morale (run_away)
390 ======
391
392 Use objects (can_use)
393 ===========
394 What objects the creature can use. Note that this has largely been
395 replaced with the body location information (see further down).
396 The ones that should in general be used are can_use_shield, can_use_weapon,
397 and can_use_bow. the others are likely to be obsoleted.
398
399 e.g.
400
401 can_use_scroll 1
402 can_use_skill 1
403 can_use_range 1
404 can_cast_spell 1
405 can_use_bow 1
406 can_use_armour 1
407 can_use_weapon 1
408 can_use_ring 1
409
410 Resistances (resist_x)
411 ===========
412 The amount of resistance the object has to certain attack types or
413 environmental effects. Use negative numbers to make objects more vulnerable to
414 the effects.
415
416 e.g
417 resist_fire 60
418 resist_cold -30
419
420
421
422 ----------------------------
423 SPECIAL NOTE (IMPORTANT!!!):
424 -----------------------------
425 <del>The fields resist_*, armour, wc and dam can be
426 set in map files to customize monsters. However, if that monster can
427 be equipped with items, and actually equips some, these values will
428 get reset back to those in the clone archetype (normal values.) Thus,
429 if you want to put a wizard in that does dam 50, make sure can_use_armour,
430 and can_use_weapon are set back to 0. Otherwise, when items are equipped,
431 all the above fields will be reset to standard values.</Del>
432
433 As of 2006-12-09, this shouldn't be the case anymore: server will detect
434 modified archetypes, and store its values in a temporary archetype structure to
435 be able to recompute everything.
436
437
438 H. Generators and Creature Spawning
439 ===================================
440
441 Generators spawn monsters or other objects. By default, generators are alive
442 and visible and can be destroyed like any other monster.
443
444 H.1 Generator (generator)
445
446 If set, this object is a generator. Monsters (like mice) can be generators.
447
448 H.2 Use Inventory (use_content_on_gen)
449
450 If set, the generator will create objects from its inventory. If the inventory
451 holds more than one object, one will be randomly selected from the list each
452 time the generator creates one. If not set, the ''other_arch'' object will be
453 used.
454
455 H.3 Object to Create (other_arch)
456
457 If ''use_content_on_gen'' is not set, the generator will create copies of the
458 object set in this field.
459
460 H.4 Generator Radius (generator_radius)
461
462 The generator will spawn objects within this radius of itself. (Within a
463 square of radius*2+1 tiles centered on the generator, to be exact.) If this is
464 not set, the radius defaults to 1, for legacy behavior. Setting it to zero
465 effectively turns off the generator.
466
467 H.5 Maximum Number of Objects on Map (generator_max_map)
468
469 If this is set, it limits the number of objects the generator will create at
470 one time. Only objects on the same map are counted. If objects are destroyed
471 or leave the map, the generator will no longer count them and will be able to
472 replace them. If the generator is at its limit, the generator will still
473 remain on the map, it just will not generate anything.
474
475 H.6 Generator Name (generator_name)
476
477 This value is used by the generator for marking and identifying the objects it
478 creates, so it can count them to determine whether ''generator_max_map'' has been
479 met. This field is only used when ''generator_max_map'' is set. If
480 ''generator_name'' is not set, the generator defaults to using its ''name'', or
481 if that is not set, to ''"generator"''. If multiple generators on the same map
482 have the same ''generator_name'', they will claim the same monsters. This is a
483 feature, not a bug. :-) It means that you could have four generators in the
484 corners of a room, each named "four generators" and each with a
485 ''generator_max_map'' of 50, and they would create up to 50 total monsters, but in
486 different parts of the room, and possibly from different inventory lists.
487
488 H.7 Maximum Objects Generator Will Create (generator_limit)
489
490 This value limits how many objects the generator will create before it
491 disappears. The default is 0 (unlimited), but many of the archetypes now
492 set this to a non zero value. Upon creating the last creature, the generator
493 will be removed from the map.
494
495 H.8 Creatures Generated (generator_generated)
496
497 This should never be set in archetypes or on maps, but it may sees on
498 a swapped out map. It is the variable that holds how many monsters
499 this generator has created - it is only used if generator_limit is set
500
501 H.9 Spawn Rate Limiter (maxsp/GENERATE_SPEED)
502
503 Normally, the generate makes the monster whenever it gets its action
504 (speed_left is positive). This works fine for static generators like
505 those for orcs which don't do anything but generate monsters. However,
506 there are some monsters, like mice and centipedes, that are also generators.
507 If the speed was set low enough that the rate the generate monsters didn't
508 overwhelm the map, they would be harmless as monsters. And if these
509 creatures generated a new creature each time they got an action, map
510 would quickly be full. To limit this, maxsp is used as a limiter
511 (note within the code, GENERATE_SPEED should always be used to get
512 this field)
513
514 maxsp is basically a random limiter random()%maxsp must be zero for
515 a creature to be generated. Thus, if maxsp is 100, each time the monster
516 moves, there is a 1% chance of a new creature being made. If maxsp is 20,
517 each time the monster moves there is a 5% chance.
518
519 Making maxsp a higher value reduces the generation rate.
520
521 Note - there is a bug here, in that a spellcasting creature can not
522 be effectively limited for generator rate, since maxsp is used for both
523 its normal meaning in this case as well as generator limitation. It is
524 unlikely that one would want spell casting creature to also be a
525 generator.
526
527
528
529 I. NPC's and their life:
530 =======================
531
532 An NPC can have any combination of the following programs (flags):
533
534 FLAGS: (They are checked in the following order:)
535 - sleep (will stand still until woken)
536 - scared (will run away)
537 - random_movement (move randomly)
538 - friendly (will attack enemies of the nearest player)
539 - unaggressive (don't attack until attacked)
540 - stand_still (don't ever move)
541
542 sleep + (any) = sleep until woken, then do any of the other things...
543 neutral + random_movement = move randomly around all the time.
544 neutral (alone) = stand still until attacked, then attack and move.
545 stand_still + (any) = do anything except moving
546
547 In addition it can have run_away set to which percentage of full
548 hit-points the npc will run away at.
549
550 And then there is the NPC features made by Karl Holland (see attack_movement)
551
552 Note that scared creatures will become unafraid at some point, so it
553 is typically not useful to set this in maps or in archetypes.
554
555
556 J. NPC's Speak out
557 ==================
558
559 The message structure in a monster may contain:
560 @match <key>|<key>[...]
561 [@reply value message] (multiple possible)
562 [@question value message] (multiple possible)
563 [text]
564 [...]
565
566 This identifies what the monster will say if talked to with a text that matches
567 any keys. They keys are processed as primitive regular expressions, so some
568 characters act as match operators or metacharacters. The asterisk, caret,
569 square braces, and dollar characters are useful to some degree.
570
571 The '@reply' and '@question' lines will be sent to the client so the player knows available replies.
572 The 'value' is a text that should correspond to a @match, and 'message' is what the player
573 will actually say when saying the 'value'. If using '@reply', the server will display 'player replies: message',
574 with '@question' it will be 'player asks: message'.
575 Note that the order of @reply and @question is non significant, they can be mixed, and can probably be
576 in the middle of the message's text (though easier to put'em at top).
577 Also, 'value' can't contain spaces.
578
579 An example of usage:
580
581 @match hello|hi
582 Welcome, good friend!
583 @match bye
584 Goodbye!
585 @match sss
586 @reply yes Yes, isn't it a shame?
587 @question no No, why?
588 Whasssamatter? You got a lisssp or sssomething?
589 @match yes
590 Sssorry, me too.
591 @match ^no$
592 You're lucky!
593 @match *
594 What did you sssay?
595
596 a. Wildcard Character
597
598 ----------------------------------------------------------------------------
599 BUG ALERT!!! A key containing only '*' will match anything, but it is not
600 handled in the same way that regular expressions are normally
601 handled! This can only be considered erroneous behavior. The
602 following paragraphs in this section shall not be construed to
603 be an acceptable design for the server. For immediate best
604 results, do not use the wildcard character except in the form
605 '@match *' to avoid setting up conversations that do not
606 function correctly. On the other hand, do use it in expected
607 regular notation form, and do fix the server code bug.
608
609 http://sf.net/tracker/index.php?func=detail&aid=1778380&group_id=13833&atid=
610 113833
611 ----------------------------------------------------------------------------
612
613 If a message does not contain an '@match *', then the first key that contains
614 an asterisk will be treated as though the key was '*'. In the example below,
615 if the player says anything, the NPC will say 'Nice tune...' no matter what the
616 player says, even if it does not end with 'bug'. It will not be possible for
617 the NPC to say 'Bah, humbug to you!'.
618
619 @match hum*
620 Nice tune...
621 @match *bug
622 Bah, humbug to you!
623
624 Avoid using '*' except in the form '@match *'. If the above conversation were
625 amended to also contain a '@match *', neither the 'hum*' nor the '*bug' keys
626 would work.
627
628 In fact, '*' is not needed as used in the above examples since '@match sss'
629 operates the same way as '@match *sss*' would be expected to operate in a
630 regular expression. Because of this, be especially careful with short word
631 matches like yes/no answers to questions. '@match yes' triggers when the
632 player enters any word with 'yes' in it! If a conversation contains the word
633 'yesterday' or 'nobody', the player might type one of these words and the NPC
634 might think they said 'yes' or 'no'.
635
636 b. Word Boundaries
637
638 If you want to prevent a match string from matching partial words, use the '^'
639 and '$' metacharacters to bound the word. In the first example, the NPC only
640 responds when the player says 'no', and not when the player says any other
641 word that contains 'no'.
642
643 c. Case Insensitivity
644
645 Keys need not contain case variations even though old maps often did. For
646 example, '@match hello' works just as well as the more verbose versions like
647 '@match Hello|hello' and '@match "[Hh]ello'. The matches are done after both
648 the match list and the player text are converted to lowercase.
649
650 d. Multiple Choice
651
652 The square braces may be used to construct special matches. For example, a
653 key of '[jy]ello' would match 'jello' or even 'yellow'.
654
655 e. Quest support
656
657 As a special case, if the line just after match is 'quest xxx', then
658 the NPC will only display the text (without the quote line) if the player
659 is currently doing indicated quest. See also 'quests' document.
660
661 Obviously this feature can be expanded extensively, so expect it
662 to evolve till the next version.
663
664 f. Other Considerations
665
666 You might not want to put messages into archetype creatures, this feature is
667 more for making special NPCs for maps. However, certain generic messages in
668 archetypes might add to the general game ambiance a bit (by default: dogs
669 would say "arf arf" guards would say "move along"...) - tm
670
671 See also: http://wiki.metalforge.net/doku.php/cfdialog
672
673 ******************************************************************************
674 3. Objects in general
675 ******************************************************************************
676
677 The name in parentheses after a flag description is the name as it should be
678 used in the archetype file. For example: type field (type)
679
680 A. Names (name, name_pl)
681 ========================
682
683 If no 'name' field is specified in the object, it will use the name from
684 the 'Object' field.
685
686 The 'name_pl' field is the plural name for the object. This only needs
687 to be set if there is the potential for the object to merge with others -
688 for example, there is no reason for name_pl to be set for floors, buildings,
689 etc, as they can not merge with other objects. Only objects that can
690 be picked up really need a name_pl value.
691
692 If name_pl is not set, this name defaults to the object->name value,
693 which was either explicitly set or determined from the Object field.
694
695 These name values are what the player sees for the name. As the player
696 sees it, the name may have the title appended to it, and may also
697 have other per type specific information added in (spell contained
698 within the spellbook for example).
699
700
701
702 B. Types (type) & Subtypes (subtype)
703 ====================================
704
705 Specified in defines.h, the type field determines how an item operates/what it
706 does.
707
708 A type only needs to be added for a new archetype if it is actually used in
709 some part of the program. Addition of new types is generally a rare event.
710 For example, if adding a new monster, there is no need to add a new type
711 in defines.h if the crossfire-server never checks the type element in the
712 object structure for that new type.
713
714 Most types are set for items that are applied, items that have special
715 properties.
716
717 You should look at the include/defines.h file for the latest type information.
718 When making a map, you should almost never change the type field of an object -
719 instead, you should start with an object of an appropriate type and change the
720 fields of the object to appear as you want it to.
721
722 http://wiki.metalforge.net/doku.php/dev:object_types contains a wiki version of
723 the defines.h type definitions.
724
725 Subtypes are related to types, in that it narrows down the scope of the
726 type of object. For example, the type may be the value for skill,
727 with subtype being the different skill it uses. Or for spell objects,
728 subtype could be the spell identifier.
729
730 Subtype is a new field as of April 2003. It's use needs to be extended.
731 As example of this is with all equipment items - they should get moved
732 to be of type 'equipment', with subtype specifying exactly what it does
733 (ring, helm, armor, etc).
734
735 Note that the meaning of the subtype is specific to the type itself - they are
736 not unique across all types. For example, for type equipment, subtype 1 might
737 be a helm. But for type skills, subtype 1 might be smithery. One should not
738 rely on subtype to convey any meaningful information unless the type of the
739 object is known or also examined.
740
741 The question may then be asked - when making a new arch, when is a new type
742 needed as opposed to a new subtype?
743
744 When to add a new type:
745 1) If code to support applying the object is completely different than
746 what exists in apply.c (eg, not reusing existing functions), or
747 2) If code to support movement of the type does not reuse existing
748 functions (server/time.c)
749
750 When to make a new subtype:
751 1) New behavior is _close_ to that of an existing type, but is slightly
752 different (eg, teleporters that don't work on players), or
753 2) It is necessary to differentiate between objects of the same type. Eg,
754 addition of a new skill adds a new subtype, not a new type.
755
756 If your not sure, drop a mail to the crossfire developers list.
757
758 If there is a header file that contains all the other information related to
759 the object type, the subtype should be defined there. Otherwise, subtypes
760 should be defined in define.h. The subtype definitions should include be
761 prefixed by what they are a subtype for. Eg, SKILL_SMITHERY, SKILL_JEWELER,
762 etc, and not just SMITHERY and JEWELER. It is acceptable to abbreviate the
763 prefix if it is very long.
764
765
766 C. Client Types (client_type)
767 ==============================
768
769 Client type information in public information communicated to the client.
770 Client type differs from the type in several ways:
771
772 1) It is more specific than the type information.
773 2) The numbers used for client type are more logically grouped (all armor
774 related client_types are in the same range)
775 3) client type info does not have a functional component in the server - it
776 only conveys information - the server does not determine what an object
777 may or may not do based on this. At current time, the server does not
778 even look at the client_type for any information.
779 4) The client_type can be used to hide the real type of an item. Eg,
780 items of client_type poison should never be sent - client_type should
781 instead by booze so difficult for the client to know what the item
782 really is. similarly, special objects used in quests which appear
783 as something else (eg, a key appearing as a shovel) can use the
784 client type to have the type shown as the same category that
785 shovels would be in.
786
787 The client_type list below has large gaps - this is to allow future items
788 to be grouped with items of similar type (Eg, if a new weapon type,
789 say two-handed is added, it should be grouped with the weapons and not
790 put at the end of the table). The entire point of the client_type information
791 is to group the items together.
792
793 In the list below, the number in parenthese corresponds to the number in
794 define.h file. At the top of each group of items, the range is given. It is
795 intentional in most cases to leave the first entry of a range blank - this
796 gives room to place really important items of a type at the top. Note that
797 only items the player may be able to pick up or apply actually need types.
798
799 Note in most cases, the artifact type items are at the top of a group listing.
800 This is done for artifact items that already have a different face/name,
801 such that the player already knows they are special anyways.
802
803 client_type
804 Client Type Notes
805 1-49 Specials - items that should be very noticable to the player.
806 1 bomb (47)
807 41 power crystal (156)
808
809 50-99 Containers - put near top to make things easier for the player.
810 51 container (122)
811 51 big containers - chests, sacks, etc.
812 55 small containers (pouches)
813 60 specialized containers (quivers, key rings)
814
815 100-149 hand held weapons
816 100 Artifact weapons (15)
817 101 edged weapons (sword, scimitar, etc)
818 106 axes
819 121 clubs
820 126 hammers
821 129 maces
822 136 pole arms
823 141 chained weapons
824 145 oddball weapons (magnify glass, stake, taifu, shovel, etc)
825
826 150-199 Ranged weapons & ammo:
827 150 artifact bows (14)
828 151 bow (14)
829 159 arrow (13) Group ammo with firing type
830 161 crossbow
831 165 bolts
832
833 250-399 Armor, shields, helms, etc. Give each subtype a group
834 of 10 entries to further subdivide into. This is basically all
835 equipable items not in another group.
836
837 250-259 Bodywear (mails - 16) - ordered roughly in order of value
838 250 Artifact/special
839 251 Dragonmail - enough of these to warrant their own type
840 252 plate mails
841 253 chain mail, scale mail, & ring mail
842 254 leather armor
843 255 dress
844 256 robes & tunics
845 257 aprons
846
847 260-269 Shields
848 260 artifact shields (33)
849 261 Shields (33)
850
851 270-279 Headwear (34)
852 270 artifact helmets (34)
853 271 Helmets (34)
854 272 turbans (34)
855 273 wigs (34)
856 275 eyeglasses (34)
857
858 280 artifact cloaks (87)
859 281 cloaks (87)
860
861 290 artifact boots (99)
862 291 boots (99)
863
864 300 artifact gloves (100)
865 301 gloves (100)
866 305 gauntlets (100)
867
868 310 artifact bracers (104) - god given
869 311 bracers (104)
870
871 321 girdle (113)
872 381 amulets (39)
873 390 artifact rings (70)
874 391 rings (70)
875
876 450-459 Skill objects - these are items that give you a skill, eg
877 lockpicks, talismens, etc.
878 451 skill (43)
879 461 trap parts (76)
880
881 600-649 Food & alchemy related items. Flesh items double as both
882 eatabls and used in alchemy. Thus, we include the
883 inorganic items here so that most all the alchemy stuff
884 is located in the same general place in the inventory.
885 601 Food (6)
886 611 Poison (7)
887 611 drink (54)
888 620 Flesh item (72)
889 622 corpse (157) Used for raise dead spells
890 624 flesh items, quasi food - dragon steak
891 625 flesh item - heads, eyes, tongues, teeth (72)
892 626 flesh item - legs, arms, hands, feet, fingers, etc.
893 627 flesh item - misc - ichors, scales, hearts, livers, skin (72)
894 628 flesh items - dusts
895 641 inorganic - raw (73)
896 642 inoranic - refined (true lead, mercury, etc)
897
898 650-699 Single use spell casting items (scrolls, potions, balms)
899 651 potion (5)
900 652 balms, dusts (5)
901 653 figurines (5)
902 661 scroll (111)
903
904 700-749 Ranged spell casting items
905 701 rod heavy (3)
906 701 rod light (3)
907 711 wand (109)
908 712 staff
909 721 horn (35)
910
911 800-849 Keys
912 801 normal key (24)
913 810 special key (21) (archetype)
914 811-839 special keys that maps can override the value into. In this
915 way, all the special keys for a dungeon can be given the same
916 client type so they group together. Note that the map needs
917 to be modified to change the client_type of the keys to do this.
918
919 1000-1049 Readables
920 1001 mage Spellbook (85)
921 1002 cleric spellbooks (85)
922 1011 Armor improver (123)
923 1016 weapon improver (124)
924 1021 Skill scroll (130)
925 1041 Books & scrolls - information type objects (8)
926
927 1100-1149 Light emitting objects & lightables
928 1101 lighter (75)
929 1102 torch
930 1103 colored torches
931
932 2000-2049 Valuables - only real value is monetay
933 2001 money (36)
934 2005 gold nuggets
935 2011 gems (60) - this could be divided into more subtypes - probably better
936 for artifact gems to have a different type than worry about sorting
937 ruby, diamond, emerald, etc.
938 2030 Jewelery (60) - chalice, crystball
939
940
941 8000-8999 Misc - items of no specific use or can not easily be sorted.
942 8001 clock (9)
943 8002 furniture (15) - These can be used as weapons, but probably
944 shouldn't be.
945 8003 ten kilo
946 8006 bagpipe (24) - this is type key, probably shouldn't make it that obvious
947 8011 gravestone (38)
948 8012 boulders
949 8013 pillars
950 8015 flowers
951 8020 ice cubes
952 8021 transforming items
953
954 25000-25999 Non-inventory items, stuff stuck to the floor, that can be applied.
955 25011 Town portal (66)
956 25012 Exits, doors, buildings - much more mundane exits (66)
957 Note to arch writers; only need to set the client_type on
958 the head (this is the case for all other properties as
959 well).
960 25021 Ordinary signs (98), Shop Inventory (150)
961 25031 Imperial Post Office postboxes
962 25041 Slot machines
963 25042 Trigger (27), levers (93)
964 25091 Bed to reality (106)
965
966 D. Animations (anim - mina) (facings)
967 =====================================
968
969 This section will briefly try to explain how all the animation values
970 (anim_speed,last_anim, FLAG_IS_TURNING and FLAG_ANIMATE work together.)
971
972
973 In the archetype specification, there is a anim/mina sequence which lists
974 faces are used for animations. An example for the big dragon follows:
975
976 anim
977 dragon.171
978 dragon.172
979 dragon.173
980 dragon.172
981 dragon.131
982 dragon.132
983 dragon.133
984 dragon.132
985 mina
986
987 Anything that is animated must have such a sequence.
988
989 FLAG_ANIMATE (anim, mina)is used to inform crossfire that this object should
990 be constantly animated. A case where an anim section as above is used but
991 FLAG_ANIMATE is not set is for arrows and other objects in which the anim
992 field is instead used to determine what face to draw for different facings of
993 the object.
994
995 facings is used in conjunction with FLAG_ANIMATE. This is a states the number
996 of facing the objects has (2, 4, or 8 - 1 is the default). the number of faces
997 in the anim/mina sequence must be a multiple of num facings..
998
999 here is an example of using animation and facings:
1000
1001 anim
1002 facings 2
1003 fred.131
1004 fred.132
1005 fred.171
1006 fred.172
1007 mina
1008
1009 The facings go clockwise (1 north (up), 3 east (right), 5 south (down),
1010 etc).
1011
1012 If there are fewer than 8 facings (which is typical), the same rotational
1013 order is kept. So with only 2 facings, the first half in the group will be
1014 used when the creature is pointing to the right, second half to the left.
1015
1016
1017 anim_speed is used to determine how often the object is animated. If
1018 anim_speed is 0, then the object is animated anytime it gets an action.
1019 If anim_speed is nonzero, then every anim_speed ticks, the object is
1020 animated (irregardless of how fast the item is) last_anim is used internally
1021 only to determine how many ticks have passed since the item was last
1022 animated. anim_speed is useful for objects that otherwise move very
1023 slowly but which need to be animated more often. Note: If anim_speed
1024 is used, the object must still have a nonzero speed for it to work.
1025
1026 In terms of frequency of animations, 1/anim_speed = object speed.
1027 Thus if an object has speed of 0.2, its anim_speed is effectively 5.
1028
1029
1030
1031 E. Material types (material)
1032 ============================
1033
1034 Material bit
1035
1036 Paper 1
1037 Iron 2
1038 Glass 4
1039 Leather 8
1040 Wood 16
1041 Organic 32
1042 Stone 64
1043 Cloth 128
1044 Adamantite 256
1045
1046 The objects material affects how saving throws against an object affect it.
1047 Thus, if paper is hit by fire, it tends to burn up, while iron does not. You
1048 can look in common/living.c to see the exact values. Note that if the material
1049 type is 0 (no material) or is Adamantite, the object can not be harmed in
1050 any way.
1051
1052 An object can have multiple material types by adding these values together.
1053
1054
1055 F. Item Power (item_power)
1056 ===========================
1057
1058 item_power measures how powerful and item is. This information is only
1059 relevant for items that are equipped - one time use items, monsters,
1060 walls, floors, do not use this.
1061
1062 When a player tries to equip something, the code goes through all the objects
1063 the player currently has equipped and sums up their item_power. The
1064 item_power of the object the player is trying to equip is also added. If
1065 this total exceeds the characters level, he is not allowed to equip the
1066 item.
1067
1068 In simple terms, the sum of all the players equip items item_power must
1069 be less than the characters level.
1070
1071 Powerful items should have a higher item_power value. This basically
1072 acts as a way to balance the items. It also prevents gifts from high
1073 level characters to newbies from being very useful - the item_power may
1074 prevent the low level character from equipping this items.
1075
1076 For items automatically generated by the treasure code, the following
1077 formula is used:
1078
1079 # enchantments power
1080 0 0
1081 1 0
1082 2 1
1083 3 2
1084 4 3
1085 5 4
1086 6 4
1087 7 7
1088 8 9
1089 9 11
1090 10 13
1091 11 15
1092 12 18
1093 13 21
1094 14 24
1095 15 27
1096 16 30
1097 17 35
1098 18 40
1099 19 45
1100 20 50
1101
1102 An enchantment is:
1103 Each plus an item has.
1104 Each point an item increases an ability.
1105 Each 20% protection an item gives (rounded normally, eg 0-9 counts as nothing,
1106 10-29 counts as one, etc)
1107 Each attacktype a weapon has.
1108 Spell path adjustments ( denied paths -2 )
1109
1110 These properties have the following enchantment value
1111 *lifesaving 5
1112 *reflect spells 3
1113 *reflect missiles 2
1114 *stealth 1
1115 *xray vison 2
1116 *see in dark 1
1117 *invisibility 1
1118 *slay 2
1119
1120 This same formula can be used for custom objects to figure out their
1121 item power.
1122
1123 While the item_power field in the object structure is signed, in general,
1124 there should not be objects with a negative item power. However, negative
1125 effects an item has may reduce the item power. Eg, a
1126 'sword +4 (str +2)(wis -3)' would really be 3 enchantments.
1127
1128 FIXME - add settings explanation, ensure information is correct.
1129
1130 G. Body Location
1131 ==================
1132
1133 The body locations information determines where the item is equipped onto
1134 the character. If the character does not have the slot available,
1135 they are prevented from equipping the item.
1136
1137 Some races may have a value of 0 for some locations, this denotes that they
1138 can not use that particular item (just won't fit on them).
1139
1140 For monsters/players, the body location information is positive values -
1141 this denotes how many locations they have for the different slots.
1142
1143 For items, the body location is negative, this denotes the spaces it
1144 uses up. Note that if multiple locations are set in an item, all of those
1145 spaces must be available to wear it (it is an AND operation, not an OR).
1146 Thus something that has body_neck -1 and body_head -1 means that both the
1147 head an neck must be available.
1148
1149 Currently defined list of locations:
1150 load/save name # for humans What object types use it
1151 body_range 1 Rod, horn, wand
1152 body_arm 2 bows (2), weapon, shield
1153 body_torso 1 armour
1154 body_head 1 helmet
1155 body_neck 1 amulet
1156 body_skill 1 skills (holy symbols, talismen, lockpicks,
1157 writing pens)
1158 body_finger 2 rings
1159 body_shoulder 1 cloak
1160 body_foot 2 boots
1161 body_hand 2 gloves
1162 body_wrist 2 bracers
1163 body_waist 1 girdle
1164
1165 FIXME - Add information for legs.
1166
1167 Using body information:
1168
1169 Using this information is quite easy - for objects, just add the appropriate
1170 body_.. with a negative value. For monsters, put those in with a positive
1171 value. If a monster has a location to use an object, is is presumed in the
1172 code that the monster should pick up/equip objects into that location.
1173 Thus, setting these for monsters may not really match what they have,
1174 eg, kobolds have arms, but it is still set to 0 so that they won't equip
1175 things. The above information largely replaces the CAN_USE information.
1176
1177 Note that the unqualified names above only refer to human locations. New
1178 locations for dragons or other creatures can easily be added.
1179
1180 Adding body locations:
1181
1182 The steps for adding a body location is as follows:
1183
1184 1) Update the table above for documentation purposes.
1185 2) Update the NUM_BODY_LOCATIONS in include/object.h.
1186 3) Update the body_locations structure in common/item.c. Be sure to read
1187 the comments above the structure.
1188 4) recompile
1189 5) create some items that use these new locations.
1190
1191 Note that most the code itself sees all this as abstract - it doesn't know
1192 what goes in what location, or even what each location is called.
1193 However, a few bits do care - the skill stuff checks to see if you have
1194 any arms free - thus, BODY_ARMS is defined so we know if the player
1195 does or does not. The alternative to this would be to have the
1196 skill stuff do a strcmp, but then we are defining the name - easier
1197 to just presume that the location won't change in the body_locations
1198 table - there is no reason that it should.
1199
1200 H. Meaning of certain attributes for certain items:
1201 ====================================================
1202
1203 All objects have strength, intelligence, wisdom, dexterity, constitution,
1204 charisma, experience, and spell points. However, how each is used
1205 varies for different objects. Here is a PARTIAL rundown:
1206
1207 For rings, str, int, wis, dex, con and cha are modifiers to the users
1208 abilities.
1209
1210 For treasures (chests, random_???), hp is the number of items that
1211 should be generated. A chest with hp of 5 will generate 5 treasures,
1212 a random_scroll space with hp of 5 will generate 5 random scroll types (of
1213 which, each scroll type may number more than one - see the treasures
1214 file for more information.)
1215
1216 For shop floors and treasures, exp is the difficulty to use for
1217 creating the treasure. If exp is 0 (which it is by default), then the
1218 map difficulty is used instead.
1219
1220 For armour, last_sp (ARMOR_SPEED) is the maximum speed that the
1221 character can have while wearing that armor.
1222
1223 For armour, last_heal determines the penalty for spell point regeneration.
1224
1225 For exits:
1226 slaying = The map which the exit leads to.
1227 hp,sp = (x,y) of the destination on the new map.
1228
1229
1230 All items that can be applied, including items, exits, handles, and thus
1231 can have a 'race_restriction' key. The value should be set to a : delimited
1232 list of races that will be able to use/apply/open this item.
1233 The list is in the form:
1234 :race1:race2:...:racen:
1235 with leading and trailing :.
1236 Note that that this only applies to players - monsters can always apply everything.
1237 Also, Dungeon Masters are immune.
1238
1239
1240 I. Lore
1241 ============================================================
1242
1243 Lore is a free form text field similar to the msg bug. Its syntax is
1244
1245 lore
1246 ..
1247 ..
1248 endlore
1249
1250 while msg's meaning is dependent on the object, lore is consistent - it
1251 should contain background information on the object, or other somewhat general
1252 details about the object. It will be put into books, possibly used by npc's
1253 and other places where general knowledge should be presented.
1254
1255 J. MOVEMENT TYPES
1256 ============================================================
1257
1258 The movement types (MOVE_..) is a bitmask that determines which method
1259 of locomotion the object is using, and is also used to determine what
1260 types of movement the space blocks. From define.h:
1261
1262 #define MOVE_WALK 0x1 /* Object walks */
1263 #define MOVE_FLY_LOW 0x2 /* Low flying object */
1264 #define MOVE_FLY_HIGH 0x4 /* High flying object */
1265 #define MOVE_FLYING 0x6 /* combo of fly_low and fly_high for easier checking */
1266 #define MOVE_SWIM 0x8 /* Swimming object */
1267 #define MOVE_BOAT 0x10 /* Boats/sailing */
1268 #define MOVE_ALL 0x1f /* Mask of all movement types */
1269
1270 MOVE_ALL may change in the future - it is mask for all movement types -
1271 it sets move_block to MOVE_ALL, other places that check for all movement types
1272 may also use this value.
1273
1274 It is possible to use string names instead of the numeric bitmask in the
1275 move_fields below. It is strongly encouraged that the string names be used for
1276 improved readability. In addition, using string names, especially 'all', will
1277 result in easier maintainability in the future. For example, if you specify
1278 'move_block 31' right now, that is equivalent of all. However, if new move
1279 types are added, using a numeric option will not block the new movement types,
1280 where if 'move_block all' was used, it continue to block everything.
1281
1282 The string names are same as the MOVE_ defines, but with the MOVE_ portion
1283 removed, eg, 'walk', 'fly_low', 'fly_high', etc. Multiple types can be listed,
1284 separated by a space. In addition, a - (minus) can precede the name, which
1285 means to negate that type. These are all equivalent:
1286
1287 move_block 6
1288 move_block fly_low fly_high
1289 move_block flying (special symbolic name)
1290 move_block all -swim -walk -boat
1291
1292 Note the order when using the -(negation) is important - the string is parsed
1293 left to right. This is not equivalant to the above:
1294
1295 move_block -swim -walk -boat all
1296
1297 Because it will clear the swim, walk and boat flags, and then set the flags to
1298 all.
1299
1300 Also, using only negation is not allowed - you can not do:
1301
1302 move_block -walk
1303
1304 To indicate you want to remove only the walk blocking from the archetype -
1305 you must include a positive indicator.
1306
1307 For all practical purposes, using negation only makes sense if using the
1308 keyword 'all'. However, if more movement types are added, with symbolic names
1309 that include several movement types (eg, MOVE_LAND), using the negation with
1310 those names may make sense.
1311
1312 Be aware that when the field is saved out, it may not be saved exactly as it
1313 was specified in the load file. This is because the server converts the
1314 string to an int at load time, then converts it back to a string.
1315
1316 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1317 The fields in the object themselves:
1318
1319 move_type: Bitmask of above values which determines what form of movement
1320 this object uses. For objects equipped by player/monster, move_type grants
1321 that movement.
1322
1323 Note that move_type of MOVE_FLY (0x2) replaces FLAG_FLYING.
1324
1325 In general, creatures will only have 1 movement type active at a time.
1326
1327 move_block: Represents what movement types are unable to pass this space.
1328 If the creature has multiple movement types, they may still be able
1329 to pass the space. For example, a player has MOVE_WALK | MOVE_FLY.
1330 He tries to move onto a space that blocks MOVE_WALK - not a problem,
1331 a he just flies over.
1332
1333 move_allow: This overrides move_block - basically, this allows movement
1334 of the specific type on the space, regardless of move_block of other
1335 objects on the space. This is most useful to set on objects that
1336 should temporary change the characteristics of the space.
1337
1338 move_on/move_off: Take bitmasks - represents for what movement types
1339 this object is activated on. Replaces the walk/fly_on/off values
1340
1341 move_slow: Like move_block, but represents what movement types are slowed on
1342 this space. Note that it is not possible to specify different penalties for
1343 different movement types in the same object. However, multiple objects with
1344 different move_slow values (and penalties) can be put on the same space.
1345 This replaced FLAG_SLOW_MOVE, which is converted to only slow down walking
1346 movement.
1347
1348 move_slow_penalty (was slow_move) - how much the player is slowed down.
1349 This value is a float (before it was an int converted to a float
1350 at load time). It is basically how much slower (percentage wise)
1351 the player moves through this terrain. A value of 0 is basically
1352 a non operation. A value of 0.5 means it takes 50% longer to move
1353 through the space. The old values were all positive ints. Basically,
1354 it effectively was how many ticks the player is slowed down by.
1355
1356 Certain terrain has skills which reduce the slow penalty (woodsmen
1357 in forest for example). As of this writing, the penalty is reduced
1358 to 1/4 of what it would be. Eg, a move_slow_penalty of 1.0 would
1359 say it takes twice as long to move through the space. If the player
1360 has appropriate skill, it would now only take that player 25%
1361 longer to move through the space.
1362
1363 Note 2: The old slow_move is loaded and converted into move_slow_penalty.
1364 The old SLOW_PENALTY and SET_SLOW_PENALTY macros divided/multiplied
1365 the result by 1000, so were basically a non operation. Since it is now
1366 just stored as a float, conversion macros are not needed or used.
1367
1368 move_state/move_status: This is unrelated to this movement code - it is
1369 used for monster attack_movement information. it is only noted here
1370 since it starts with the move_ prefix.
1371
1372 msg/endmsg: If an object has move_block of move_slow and that affects
1373 the player movement, the objects message will be printed to the player -
1374 thus things like 'The jungle slows you down' or 'The wall is in the way'
1375 will be printed. Various hints can be contained in the messages.
1376
1377 move_status: Not related to this code - noted here since it has the move_
1378 prefix. This is used to track monsters state of the attack_movement
1379 variable. It is worth noting that move_type was changed to
1380 attack_movement - this matches the name in the archetype, but is
1381 a name change in the object field.
1382
1383 Obsoleted fields:
1384 This change of logic has resulted in the following fields no longer
1385 being used:
1386 FLAG_WALK_ON -> move_on
1387 FLAG_NO_PASS -> move_block
1388 FLAG_SLOW_MOVE -> move_slow
1389 FLAG_FLYING -> move_type
1390 FLAG_WALK_OFF -> move_off
1391 FLAG_FLY_ON -> move_on
1392 FLAG_FLY_OFF -> move_off
1393 FLAG_PASS_THRU -> was unused, would be move_type
1394 FLAG_CAN_PASS_THRU -> was unused, would be move_type
1395
1396
1397 Special player notes:
1398 Player can only pick up items if MOVE_WALK is set (this may need
1399 to be expanded down the road). Basic idea is that if you are flying,
1400 can't reach the ground, if swimming, don't really have any free hands
1401 to grab anything.
1402
1403 Misc fields:
1404 Those fields are kind of used by all objects, but aren't really in the previous
1405 parts.
1406
1407 * death_animation (key/value): should point to a valid archetype name that
1408 will be inserted in the map when the object dies. It should probably be a
1409 one-time animation (''is_used_up 1'').
1410
1411 ******************************************************************************
1412 4. SPECIAL OBJECTS
1413 ******************************************************************************
1414
1415
1416 A. MAPS:
1417 ========
1418 see doc/map-technical for this information.
1419
1420
1421 B. HOLY_ALTARS
1422 ==============
1423 (re-done code by Mark Wedel)
1424 Holy altars are altars for the various religions. Praying at a
1425 holy_altar will make you a follower of that god, and if you already follow
1426 that god, you may get some extra bonus. Meaning of the fields
1427
1428 level: To re-consecrate an altar, the players skill level must be as
1429 high or higher than the level field. In this way, some altars can not
1430 be re-consecrated, while other altars, like those in dungeons, could be.
1431
1432 other_arch: The god that this altar belongs to. This replaces the
1433 title field that used to be used.
1434
1435
1436 C. DISEASES
1437 ===========
1438 by Peter Mardahl
1439
1440 The following describes some things about the archetype
1441 and implementation:
1442
1443 Stat Property Definition
1444
1445 attacktype Attack effects Attacktype of the disease. usu. AT_GODPOWER.
1446 other_arch Creation object created and dropped when symptom moved.
1447 wc+ Infectiousness How well the plague spreads person-to-person
1448 magic+ Range range of infection
1449 Stats* Disability What stats are reduced by the disease (str con...)
1450 maxhp+ Persistence How long the disease can last OUTSIDE the host.
1451 value TimeLeft Counter for persistence
1452 dam^ Damage How much damage it does (%?).
1453 maxgrace+ Duration How long before the disease is naturally cured.
1454 food DurCount Counter for Duration
1455
1456 speed Speed How often the disease moves.
1457 last_sp^ Lethargy Percentage of max speed--10 = 10% speed.
1458
1459 maxsp^ Mana deplete Saps mana.
1460 ac^ Progressiveness How the diseases increases in severity.
1461 last_eat*^ Deplete food saps food if negative
1462
1463 exp experience experience awarded when plague cured
1464 hp*^ ReduceRegen reduces regeneration of disease-bearer
1465 sp*^ ReduceSpRegen reduces spellpoint regeneration
1466
1467 name Name Name of the plague
1468 msg message What the plague says when it strikes.
1469 race those affected races the plague strikes (* means everything)
1470 level Plague Level General description of the plague's deadliness
1471
1472 last_grace Attenuation reduction in wc per generation of disease.
1473 This builds in a self-limiting factor.
1474
1475 last_heal Immunity If set, will not grant immunity when cured
1476 naturally
1477
1478 Explanations:
1479 * means this # should be negative to cause adverse effect.
1480 + means that this effect is modulated in spells by ldur
1481 ^ means that this effect is modulated in spells by ldam
1482
1483 attacktype is the attacktype used by the disease to smite "dam" damage with.
1484
1485 wc/127 is the chance of someone in range catching it.
1486
1487 magic is the range at which infection may occur. If negative, this is
1488 not level dependent.
1489
1490 Stats are stat modifications. These should typically be negative.
1491
1492 maxhp is how long the disease will persist if the host dies and "drops" it,
1493 in "disease moves", i.e., moves of the disease. If negative, permanent.
1494
1495
1496 value is the counter for maxhp, it starts at maxhp and drops...
1497
1498 dam if positive, it is straight damage. if negative, a %-age.
1499
1500 maxgrace how long in "disease moves" the disease lasts in the host, if negative,
1501 permanent until cured.
1502
1503 food if negative, disease is permanent. otherwise, decreases at <speed>,
1504 disease goes away at food=0, set to "maxgrace" on infection.
1505
1506 speed is the speed of the disease, how fast "disease moves" occur.
1507
1508 last_sp is the lethargy imposed on the player by the disease. A lethargy
1509 of "1" reduces the players speed to 1% of its normal value.
1510
1511 maxsp how much mana is sapped per "disease move". if negative, a %-age is
1512 taken.
1513
1514 ac every "disease move" the severity of the symptoms are increased by
1515 ac/100. (severity = 1 + (accumulated_progression)/100)
1516
1517 last_eat increases food usage if negative.
1518
1519 last_grace Reduction in the diseases' contagiousness everytime it infects someone
1520 new. This limits how many generations a disease can propagate.
1521
1522
1523
1524 For SYMPTOMS:
1525
1526 Stats modify stats
1527 hp modify regen
1528 value progression counter (multiplier = value/100)
1529 food modify food use (from last_eat in DISEASE)
1530 maxsp suck mana ( as noted for DISEASE)
1531 last_sp Lethargy
1532 msg What to say
1533 speed speed of movement, from DISEASE
1534
1535
1536
1537 D. CONVERTERS:
1538 ==============
1539 other_arch = which archetype to convert into
1540 slaying = which archetype to convert from
1541 sp = how many other_arch to create
1542 food = how many items are needed to convert into <sp> other_arch
1543
1544
1545
1546 E. BOWS & ARROWS:
1547 =================
1548 Missile weapons
1549
1550 Missile weapons (type BOW) can be used to shoot missiles (type ARROW). The most
1551 common weapons are bows and crossbows but other weapons are also easy to
1552 implement (e.g. a sling). The following variables have the same meaning for
1553 both weapons and bullets:
1554
1555 race type of missile (indentifies weapon and missile pairs)
1556 dam the basic damage
1557 wc the basic wc
1558 magic the magic bonus
1559
1560 And these two used only for arrows.
1561
1562 hp the basic damage (internal use)
1563 sp the basic wc (internal use)
1564 food the breaking probability after a shot (0-100)
1565
1566 And these two are for bows.
1567
1568 sp the shooting speed (% of normal speed, 1-100)
1569 no_strength player's strength or monster's level doesn't affect
1570 the damage done by bow.
1571
1572 The other variables has their normal meanings.
1573
1574
1575
1576 F. object creating objects
1577 ==========================
1578 by peterm
1579 What a creator is, is an object which creates another object when it is
1580 triggered. The daughter object can be anything. (yet another way other
1581 than runes to create surprise monsters, though runes are better for that,
1582 they're smarter at placing monsters)
1583
1584 You've seen a creator demonstrated if you've solved the Tower of
1585 Demonology: when you summon a demon you also get some firetrails
1586
1587 Creator object: an object which creates other objects. It is usually
1588 invisible.
1589
1590 other_arch the object to create
1591 connected what will trigger it (button, magic ear)
1592 hp number of times to create before dissappearing
1593 lifesave if 1, it will create the object every time it's triggered,
1594 and never disappear
1595 slaying the name the created object will bear
1596 level the level the created object will have
1597
1598
1599 G.Player Movers
1600 ===============
1601 by peterm
1602
1603 Player movers are objects which move objects above them. These objects
1604 must be alive. They are directional, so players can be made to move in
1605 a pattern, and so can monsters.
1606
1607 Motion is involuntary. Additionally, players or monsters can be paralyzed
1608 so that they MUST move along a chain of movers.
1609
1610 Multi-square monsters can be moved by movers, however enough space is required.
1611
1612 Here is the meaning of various fields:
1613
1614
1615 attacktype: if nonzero, paralyzes anyone it moves (so they are forced to
1616 move along a chain). Default values is 0
1617
1618 maxsp: the number of moves that the paralysis will rob the player of,
1619 if unset, and attacktype is nonzero, this becomes 2. By default,
1620 it is zero.
1621
1622 move_type: What movement types this mover moves (replaces maxhp to denote
1623 flying creatures)
1624
1625 speed: how fast a chain of these will move a player along (default -0.2)
1626
1627 sp: the direction--if unset (0) motion is random.
1628
1629 level: if nonzero, players will be moved as well as monsters. 0 by default.
1630
1631 lifesave: whether it can be used up, meaning is opposite, it may go away
1632 if lifesave is set. default is not set.
1633
1634 hp: if lifesave is set, the number of times (-1) it will move a player
1635 (i.e., it will move someone hp+1 times before it vanishes.). default
1636 0
1637
1638 subtype: a bitmask that specifies which of arch, name, and race affect the
1639 race and slaying flags. If unspecified (or zero), all will be searched.
1640 The LSB is arch, the next bit is name, and the third bit is for race.
1641 Table for the lazy:
1642 subtype 1: only arch
1643 subtype 2: only name
1644 subtype 3: arch or name
1645 subtype 4: only race
1646 subtype 5: arch or race
1647 subtype 6: name or race
1648 subtype 7: all three
1649
1650 race: only affect objects with a arch/name/race matching this.
1651
1652 slaying: don't affect objects with a arch/name/race matching this.
1653
1654 Note from Mark: Player Movers and Directors are separate objects, even
1655 though they look and act similar. Directors only do spells/missiles,
1656 however, while player movers only do living creatures (depending on how it
1657 is set)
1658
1659 H. Directors
1660 ============
1661 Directors are objects that change the direcion of objects moving through the
1662 air such as spells and missiles. As in the noted in the section on player
1663 movers, they act similar, however in contrast they only affect spells,
1664 missiles, or other flying projectiles.
1665
1666 Here are the various fields:
1667
1668 sp: the direction--if unset (0) motion is random.
1669
1670 subtype: a bitmask that specifies which of arch, name, and race affect the
1671 race and slaying flags. If unspecified (or zero), all will be searched.
1672 See the section above on playermovers for what subtypes mean what.
1673
1674 race: only affect objects with a arch/name/race matching this.
1675
1676 slaying: don't affect objects with a arch/name/race matching this.
1677
1678
1679
1680 I. Magical Walls -- walls that cast spells
1681 ============================================
1682 Magical walls are like other walls, except every now and then,
1683 they fire spells.
1684
1685 Magical walls can contain any spell. However, some spells do not operate
1686 very successfully in them. The only way to know is to test the spell you
1687 want to use with a wall.
1688
1689 Several types of magical walls are predefined for you in the archetypes, and
1690 can be found on a pick-map available in Gridarta.
1691
1692 If you want a magical wall which is not already defined, all you need to do
1693 is choose one of the predefined walls, and modify the 'dam' variable. The
1694 'dam' variable contains the index of the spell. See include/spellist.h to
1695 find your desired spell.
1696
1697 Meaning of archetype fields:
1698 field: Meaning:
1699
1700 dam spell the wall will cast
1701
1702 sp integer direction the wall will cast the spell. If 0,
1703 the wall will cast the spell in random direction.
1704
1705 ac armour class of wall
1706
1707 exp experience value of the wall
1708
1709 speed speed of the wall--you can fine-tune how fast the
1710 wall will cast spells
1711
1712 alive 1 means it can be attacked, 0 means not
1713
1714 hp, maxhp hit points
1715
1716 immune immunity OR mask
1717
1718 type for magical walls, this is 62
1719
1720 other_arch obsolete now, means nothing
1721
1722 maxsp has to do with turning walls. The wall will turn
1723 by 'maxsp' every time it fires, changing face.
1724 To make a wall turn, it is sufficient to set this
1725 to 1. Setting it to 8 or any multiple thereof is
1726 an exercise in futility.
1727
1728 level The level the spell will cast spells at. Level 1
1729 walls will cast spells at minimal strength. Level 100
1730 walls will cast deadly spells.
1731
1732 connected either rotate the wall or trigger it. If triggering,
1733 set speed to 0 for best results.
1734
1735
1736 J. Containers
1737 =============
1738 container <xxx> : the maximum weight the container can hold
1739 (stored internally in weight_limit)
1740
1741 Str <xx> : reduces the weight of the objects in the container
1742 0 == no reduction, 100 = weightless
1743
1744 slaying : only let items of this type in the container
1745
1746 Key/value fields that can be used (trunk only):
1747
1748 face_opened : face name (including the final ''.111'') to use when
1749 the container is opened. Will default to
1750 ''other_arch->face'' if not defined.
1751
1752 face_closed : face name to use when the container is closed. Will
1753 automatically be set if a custom face is defined, so
1754 not required to set it manually.
1755
1756 K. Mood Floors
1757 ==============
1758 ("Brian Thomas" <[email protected]>)
1759 last_sp field is used to determine what will happen to the monster
1760 when the floor is activated:
1761
1762 (based on value that last_sp takes):
1763 0: 'furious' Makes all monsters aggressive
1764 1: 'angry' As above but pets are unaffected
1765 2: 'calm' Makes all monsters unaggressive
1766 3: 'sleep' Puts all monsters to sleep
1767 4: 'charm' Makes monster into a pet of person
1768 who triggers the square. This setting
1769 is not enabled for continuous operation
1770
1771
1772 L. Altars, Triggers, Detectors and other connected items:
1773 =========================================================
1774 Note: This is not quite complete documentation, but is correct as far
1775 as it goes (0.92.1)
1776
1777 slaying: What the sacrifice must match. It either matches the archetype
1778 name (internal value only), object name, or slaying field of object.
1779 "money" is a special case - in this case, an exact name is not needed, any
1780 types of money will match.
1781
1782 food: How many objects must be sacrificed. If slaying is money, then the
1783 value of the money must be greater than the food value (ie, if food=200,
1784 then 200 sp, 20 gp, or 4 pp will all work.) Note that this is stored
1785 in a 16 bit signed value - thus the maximum is 32767.
1786
1787 msg: What to print when the altar is activated.
1788
1789 connected: A link to another object to activate.
1790
1791 sp: Spell number to cast when activated.
1792
1793 level: What level to cast the spell at.
1794
1795 hp: If set, use hp to match to that object type.
1796
1797 Note: For all sacrifice types, the number to activate the altar must be in
1798 one object. Thus, in the above money example, 100 sp and 10 gp would not
1799 work. Likewise, if the needed sacrifice was 2 swords, 1 normal sword and 1
1800 +1 sword would not work, even though 2 of either one would.
1801
1802 Quick summary of the different altars:
1803
1804 TRIGGERS:
1805 ---------
1806 TRIGGERS are slightly different than normal buttons/pedestals/whatever in
1807 that they reset after a short amount of time. Thus, they can be used to
1808 open a door for a short amount of time. Triggers use stats.wc as
1809 a temporary storage value to note activation.
1810
1811 stats.exp is used do determine when the trigger resets. A smaller value
1812 means faster reset.
1813
1814 stats.ac is used to store the old value of the condition for TRIGGER_BUTTON
1815 and TRIGGER_PEDESTAL to trigger only when condition changes from false to true.
1816
1817 TRIGGER_BUTTON: if weight on the button is greater than the weight value
1818 for the trigger, push a trigger.
1819
1820 TRIGGER_PEDESTAL: IF a matching object is on top of the pedestal, then trigger
1821 a trigger.
1822
1823 TRIGGER_ALTAR: Takes a sacrifice, then pushes a trigger.
1824 If "last_sp 0" is set, the altar will trigger the connected value TWO
1825 times per sacrifice: Once by dropping the sacrifice, second by altar reset.
1826 If "last_sp 1" is set, the altar won't trigger the connected value
1827 by reset - Hence, only ONE time per sacrifice.
1828
1829 TRIGGER (handle): Pushes a trigger.
1830 Note: At one time, there was a difference between triggers and buttons - they
1831 were considered different types for activation. However, now they are all
1832 the same - a button can push a trigger, and vice versa. And of course,
1833 triggers can activate other triggers, and the same for buttons.
1834
1835 PEDESTALS:
1836 ----------
1837 These are sort of combo buttons & altars. If the pedestals race matches
1838 the slaying of an object on top (race of player matches any player), then
1839 push the connected objects. By default, pedestals match players. They
1840 differ from buttons in that specific objects activate them (vs an amount of
1841 weight.) They are different from altars in that the object that
1842 activates them does not disappear.
1843
1844 Inventory checkers (64)
1845 -----------------------
1846 Inventory checkers passively check the players inventory to see if it
1847 contains some object. Thus, you can make portals which you can't pass through
1848 if you contain certain objects.
1849
1850 slaying: Object name we are looking for.
1851 race: archetype name we are trying to match for.
1852 hp: match on object with that type value.
1853 last_heal: Remove object if found.
1854 last_sp: If set, than having that object is a match. If 0, then not having
1855 that object is a match.
1856 connected: Value to to push.
1857 move_block: If set, you can only pass through that space if you be allowed to
1858 (depending on last_sp determines if having/not having is the match
1859 criteria.) if move_block is 0 (default), then the inventory only acts as
1860 a trigger/button.
1861
1862 General usage notes: Putting a check_inventory space in front of a gate with
1863 another on the other side works reasonably well as a control mechanism. Note,
1864 however, that other people may still be able to slip by. To get around this,
1865 use the move_block to all, and put it in the space you want to control (probably
1866 makes sense to put a fake door or other object there to make it a little more
1867 obvious what is going on.)
1868
1869 DETECTOR:
1870 ---------
1871
1872 This object samples the square its in, and if it finds an object named in the
1873 slaying field, it will trigger other objects. Detectors are a lot like
1874 pedestals - the only really difference is that they sample the space
1875 periodically, where as pedestals will get triggered the instant something is
1876 dropped. The use for pedestals is to add some indeterminate time delay
1877 (indeterminate since you can never be sure at what point in its timing the
1878 player will actually drop something on the detector.)
1879
1880 slaying name of the thing the detector is to look for. FORCEs with slaying
1881 fields matching slaying field of detector will be detected if hp is
1882 set. SPECIAL_KEY with slaying field will match when on the ground
1883 (not in inventory). If equals ''player'', will detect playersname of
1884 the thing the detector is to look for
1885 * note: FORCEs with slaying fields == slaying field of detector
1886 will be detected if hp is 1.
1887 * if 'player', will match players
1888 speed time between samples
1889 connected connected value of detector
1890 sp 1 if detection sets buttons,
1891 another value if detection unsets buttons
1892 hp non-zero if it is to search through an inventory of an object
1893 sitting over it. Note that the search only goes in the direct
1894 inventory, not recursively in all inventories
1895
1896
1897 MARKER:
1898 -------
1899 This object inserts a force into a player who stands on it.
1900 This force does nothing except contain a string in its slaying field
1901 which can be discovered by a detector.
1902
1903 slaying the code
1904 speed how quickly it will mark something standing on it
1905 food duration of the force it inserts. If nonzero, the duration
1906 is finite: about 1 food per 10 seconds
1907 name slaying field of a force to remove.
1908
1909
1910 See also the 'quests' file for special values on slaying field.
1911
1912 ------------------------------------------------------------------------------
1913 NOTE ABOUT ALL CONNECTED ITEMS:
1914
1915 Whenever an object that is connected gets activated, all other objects
1916 with the same connected tag also gets pushed. For some objects
1917 (pedestals, inventory checkers) this is likely to be meaningless. However,
1918 if something like an altar is pushed in this fashion, it will no longer
1919 be usable (only take one sacrifice, and being activated in this fashion
1920 makes it so that it looks to have been activated.)
1921
1922 One trick for connected objects that you want activated once: Set your
1923 initial connects to a set (or multiple sets) of iron spikes that are in
1924 a 2x1 enclosed area. On top of the spikes, put a boulder, and on the
1925 other space, put a large button that is then connected to whatever object.
1926 Thus, when the spikes are activated, they push the boulder to the other
1927 space, that then activates whatever is desired.
1928
1929
1930 M. Signs:
1931 ========
1932 msg: what to print when applied.
1933 food: how many times the sign can be read.
1934 last_eat: how many times the sign has been read (only used internally.)
1935
1936 If food is zero, there is no limit on how many times the sign can be read.
1937
1938
1939 N. POISONOUS BOOZE:
1940 ==================
1941 stats.hp Poison player or monster that applies this booze with stats.hp
1942 poison damage.
1943
1944 stats.hp must be greater 0 to do damage. It used to be less than 0 for
1945 -stats.hp direct damage, but that has changed. stats.hp <= 0 now means no
1946 damage at all, just loss of 25% food.
1947
1948 O. Duplicators:
1949 ===============
1950 Duplicators copy or remove objects. Duplicators are triggered objects.
1951
1952 connected: Connected value for the duplicator.
1953 other_arch: Archetype that this copies - if the archetype on top of the
1954 duplicator doesn't match this, it isn't copied. Note that it only
1955 matches the archetype - the object can then be further duplicated. For
1956 example, if other_arch is sword, it will duplicate sword +4, different
1957 attacktypes, etc, and all of those are duplicated. But it will not
1958 duplicate a dagger for example.
1959 level: The number of copies to make (1 means no changes). If set to 0
1960 the object is removed.
1961
1962 Example:
1963
1964 arch duplicator
1965 level 2
1966 other_arch sword
1967 connected 5
1968 end
1969
1970 Where 5 is connected to a lever. When the lever is pulled, if a sword object
1971 is on top, its number is doubled. If there is anything else on top, it is
1972 unaffected. If the lever it is connected to is not pulled, it is also
1973 unaffected.
1974
1975 P. Transports:
1976 ==============
1977
1978 Transports are objects that help the player move. These should not be confused
1979 with EXITS, which instaneously transport a player from one map to another.
1980
1981 Instead, transports may let the player move faster, give them move types they
1982 don't have, etc. A simple example of this would a horse. It doesn't let the
1983 player move anyplace he normally couldn't go, but lets him get there faster.
1984 Ships would be another case - the player normally can't move across water,
1985 but with a ship, he can.
1986
1987 Meaning of various object attributes (KV means the value is stored in the
1988 key/value list, and thus the get_ob_key_value() and set_ob_key_value()
1989 routines need to be used.
1990
1991 move_type The move type this object has.
1992 move_allow Normal meanings - useful for things like boats so people
1993 can actually get on the boat.
1994 speed How fast the object moves
1995 weight_limit How much this object can carry.
1996 weight_speed_ratio (KV)
1997 This value is taken as a percentage which is multiplied
1998 against against the weight this object is carrying (the
1999 player) - this is then divided by weight_limit to determine
2000 the effective loading to determine effective object speed, eg:
2001
2002 speed = base_speed - (base_speed * pl->weight *
2003 weight_speed_ratio) / (weight_limit * 100)
2004
2005 Thus, if weight_factor is 0, this object will move the same
2006 speed no matter how loaded it is. If it is 100, then
2007 if the transport is fully loaded, it moves at a crawl.
2008 In a sense, this somewhat mimics the player movement
2009 speed. Large transports, like boats, should likely be
2010 largely unaffected by weight (maybe have this value at
2011 10), where something like a horse would have a relatively high
2012 value.
2013
2014 base_speed(KV) This is only needed if weight_speed_ratio is set - it is used
2015 to know what the base speed to use in the calculation (since
2016 speed is getting clobbered). If this is not set and
2017 weight_speed_ratio is set, the archetypes speed will be used.
2018
2019 passenger_limit(KV)
2020 How many players this transport can hold. Thus, boats can
2021 transport a party (this being set to 6) while horses could
2022 only transport a single person. If this is not set, a default
2023 of 1 will be used.
2024
2025 face_full
2026 It may be desirable to have different faces to denote what
2027 the transport looks like if someone is on it vs not (mounted
2028 horse vs just a horse). This is used to denote what it will
2029 look like when loaded. If the transport becomes empty, it will
2030 fall back to the archetype face.
2031
2032 anim_full Like face_full above, but for animated objects.
2033 turnable_transport
2034 When set, the transport will change the space it occupies depending
2035 on its facing direction. The transport MUST be a square (if not, game
2036 will simple refuse to work - don't try to mess with this).
2037 The pics for directions 5 and 7 must be on the top/left corner (leave blank space
2038 at the right/bottom). See 'arch/transport/turningboat.arc' and associated pics.
2039
2040 Usage/implementation details:
2041 To activate a transport, the player will apply it just like any other object.
2042 When this is done, the pl->contr->transport will point to the transport.
2043 If the player is the first to board it, then transport->contr will point to the
2044 player. The player is placed into the inventory of the transport.
2045
2046 When on the transport, the player will see other objects on the transport.
2047 When the player issues a map command, if they are the 'captain', the
2048 transport moves as directed. If not, the move command is ignored. Note
2049 that players on the transport can issue other commands (say, cast, etc).
2050
2051 Some special handling is done relating the player and transport speed so that
2052 transport speed is used. IF the transport doesn't have speed to move,
2053 the move command is ignored. The player speed_left is set to -0.01 when
2054 on the transport - in this way, the player will get actions and not limit
2055 transport speed.
2056
2057 When aboard a transport, the player will be in the inventory of the transport.
2058 The player can see other objects in the transport. If the player drops an
2059 item, it is placed into the transport inventory, and not the map.
2060
2061 When hit_map() hits the transport, we examine look for all players in the
2062 transport and damage them as appropriate. Note that items are not
2063 damaged.
2064
2065 As of this writing, transports are non living creatures, and thus can't
2066 be damaged.
2067
2068 Q. Dragon Focus
2069 ===============
2070
2071 The dragon focus is a special item that is used during character
2072 creation - it is used to set a dragon characters elemental focus.
2073 During login, the archetype is looked up based on selection from the
2074 client. Since auto_apply is set in the archetype of the focus, the
2075 object is then automatically applied to the character.
2076
2077 The apply code finds the dragon_ability_force in the player, and copies
2078 values from the dragon focus into the dragon ability or player:
2079
2080 dragon ability->exp (which becomes attacktype)
2081 player->animation
2082 player->face
2083 player->title
2084
2085 Note: This logic could be changed with a little amount of work to
2086 work more generically for other races, allowing some degree of customization
2087 for the face.
2088
2089 R. Races & Classes
2090 ===================
2091
2092 Objects of type RACE and CLASS and objects used for initial character creation.
2093
2094 The characters base archetype becomes that of the race - thus, any fields
2095 set in the race archetype will be set in the player object - this is
2096 all fields - ac, hp, body information, see in dark, etc.
2097
2098 The actual attributes (str, dex, etc) are modifiers to the base
2099 attributes - whether these are rolled or a point system is used.
2100 Thus, Str +2 means the character gets +2 to strength.
2101
2102 For the class, the stat modifiers are also applied. Normally, the
2103 character will have the face/animation of the class - if a character
2104 choose wizard, they have a wizard looking image.
2105
2106 However, if the race contains the NOCLASSFACECHANGE object, the
2107 character will use the racial face. This is used for the nonhuman
2108 races where that is a more noticable feature than the class faces.
2109 The NOCLASSFACECHANGE can be made present by putting it in the racial
2110 treasure list.
2111
2112 For all characters, their starting skills and items is that generated
2113 from both the racial and class treasure lists. This can result in
2114 duplicate treasure in rare cases, but in general, racial treasure
2115 lists contain skills and abilities, and the class treasure list will
2116 contain items.
2117
2118 With new character creation method, additional choices can be
2119 presented to the character - the code will check for racial/class
2120 choices, and send them to the client where the player can make a
2121 choice.
2122
2123 The key/value fields are:
2124
2125 race_choice_%d archetype1 archetype2 ...
2126 race_choice_description_%d description of this choice
2127
2128 And example for dragons:
2129 race_choice_1 dragon_ability_force_fire dragon_ability_force_cold
2130 dragon_ability_force_electricity dragon_ability_force_poison
2131 race_choice_description_1 Choose a dragon focus
2132
2133 This data in a slightly different form will be sent to the client when
2134 the requestinfo class/race is made. The format for races and classes
2135 is the same, except that for classes, it will be class_choice_%d
2136
2137 Any type of items could be present here - skills, armor, weapons,
2138 spells, special abilities, etc.
2139
2140 If auto_apply is set in the archetype, it will be applied (using usual
2141 apply routines) when the character is created. This can be useful for
2142 certain items where inserting a force object does not have the desired
2143 effect - a specific example here is the dragon focuses - depending on
2144 the focus, it modifies the character object directly.
2145
2146 Note that both race_choice_%d and race_choice_description_%d must be
2147 present - if only one is present, the choices will not be sent.
2148
2149 The numeric numbers must start at one and increase by one. For
2150 example, if there is race_choice_1 and race_choice_3 (but no _2), _3
2151 will not be sent, and processing will stop once _2 is not found.
2152
2153 The reason for multiple lines is because there may be multiple
2154 disjoint choices. For example:
2155
2156 class_choice_description_1 Choose your bonus skill
2157 class_choice_description_2 Choose your starting armor
2158 class_choice_description_3 Choose your starting weapon
2159
2160 (the archetype choice is ommitted from above list to make it
2161 clearer). From that list, there are 3 different choices for the
2162 player to make - while they may be related, one can not condense those
2163 into a single entry.
2164
2165 For each choice entry, the player is only able to choose one of the
2166 values - if you want the player to be able to choose multiple values,
2167 this could be done with repeating choices with same values, eg:
2168
2169 class_choice_1 arch1 arch2 arch3 arch4
2170 class_choice_2 arch1 arch2 arch3 arch4
2171
2172 Where the archetypes in both lists are exactly the same - the client
2173 will present both lists, so the player is then able to choose 2 of the
2174 4 items. Unfortunately, there is no clear way for the client to
2175 present the player from choosing the same item twice. In some cases,
2176 this could be OK (for example, starting with 2 healing potions vs 1
2177 healing potion and one bow), but in other cases would not be good if
2178 they start with 2 of the same skill or 2 of the same spell.
2179
2180 Note it is possible here to also provide starting packages - the
2181 archetype in question could have a treasure list which gives the
2182 character several different items. A reasonable example of this might
2183 be spellcaster packages - the player chooses wizard class, then
2184 chooses from amongst the pyromance, evoker, etc, sub classes. If they
2185 select pyromancer, they get appropriate skill as well as appropriate
2186 spells for that subclass.
2187
2188
2189 *******************************************************************************
2190 5. Flags & specifications: (usage: flag value)
2191 ******************************************************************************
2192 Note: the flags are case sensitive.
2193 G = generator. O = object.
2194
2195 Note (961129): These notes look correct as far as they go. However,
2196 oftentimes, the real effect in game terms might be more complicated than
2197 list here. As an example: Exp value is just base - it will be further modified
2198 based on stats, levels, and potentially skills.
2199
2200 Flag syntax Value
2201 =========== =====
2202 Object <name> name of O, internal refs only.
2203 name <name> name of O as seen in the game.
2204 race <name> race of O, internal.
2205 slaying <name> Those O's with this race receives 2x damage.
2206
2207 other_arch <other obj> which other O this G generates.
2208 More use between linked object defs.
2209
2210 anim
2211 . which bitmaps to use in animation of the O.
2212 . If TEAR_DOWN flag is set, this contains the different
2213 . stages of being destroyed.
2214 face name Name of the face (ie, food.111). This may only be set
2215 . in the arches, not in maps.
2216 .
2217 mina
2218 end terminates definition of this O.
2219
2220 last_heal <no> Internal use (for regaining hit-points)
2221 last_sp <no> Internal use (for regaining spell-points)
2222 last_eat <no> Internal use (for consuming food)
2223
2224 speed <no> speed of O. A negative number means that speed_left
2225 will be randomized when the object is loaded.
2226 speed_left <no> speed of O remaining, internal.
2227 face <bmap no> bitmap first drawn for O.
2228 Str,Dex,Con,
2229 Wis,Cha,Int <no> default ability for O.
2230 hp,maxhp,sp,maxsp <no> default value for O hitpoints, spellpoints.
2231 maxsp In main.c:fire() which arrowtype to use
2232 Number equal to to the arrows type definition.
2233
2234 exp <no> Xp gained for killing O.
2235 food <no> nutrition value for O. *DANGEROUS* as it's also
2236 used to contain internal values for non-edible
2237 objects. This should be changed in future.
2238 dam,wc,ac <no> default damage, weaponclass, armorclass.
2239 dam 0 gives a 'friendly' monster ;)
2240 wc main.c:move_gate(). Is used by gates to indicate in
2241 which position they are.
2242 x,y <no> relative coords for bmap when using large objects.
2243 x=y=0 is default, x=1 is second bmap in first row etc.
2244 nrof <no> No. of O:s. 0 means that objects of this type
2245 are not to be joined/split (it's a lone object).
2246 level <no> O:s level.
2247 direction In which direction (1=north, 8=north-west) this O is
2248 moving (flying). Simple schematic of the dirs:
2249 812
2250 7-3
2251 654
2252
2253 type <no> the object as defined in 'defines.h'
2254 material <no> the sum of materials in this O. (see materials.)
2255 value <no> the value for this O.
2256 weight <no> the weight for this O.
2257 carrying sum of the weight of objects within this object.
2258
2259 attacktype <no> type of attack from O. (see attacks)
2260
2261 invisible <1> set if O is invisible.
2262 magic <no> magic modifier of O. (bracers +3 has magic 3)
2263 state internal. Used when animating the object
2264 alive <1> set if O is alive (can be attacked).
2265 applied set if object is readied/worn/etc.
2266 unpaid set if object is unpaid (internal)
2267
2268 no_pick <1> set if O can't be taken.
2269 no_pass <1> set if O can't be passed. (eg, a closed door) (obsolete
2270 -- use move_block all instead)
2271 walk_on <1> O is applied by anything walking onto it. (obsolete --
2272 use move_on walk instead)
2273 walk_off <1> O is applied by anything walking off it. (obsolete --
2274 use move_off walk instead)
2275 fly_on <1> O is applied by anything flying onto it. (obsolete --
2276 use move_on fly_low instead)
2277 fly_off <1> O is applied by anything flying off it. (obsolete --
2278 use move_off fly_low instead)
2279 is_animated <1> set if O is animated.
2280
2281 flying <1> set if O is flying. (obsolete -- use move_type fly_low
2282 instead)
2283 monster <1> set if O is a monster.
2284 friendly <1> set if O will help player instead of attacking.
2285 generator <1> set if O is a generator.
2286 auto_apply <1> O is applied when it is loaded (for instance, some
2287 chests open automatically when the map is loaded)
2288 treasure <1> not used yet.
2289
2290 apply_once <1> not used yet
2291 see_invisible <1> set if O can see invisible player.
2292 can_roll <1> set if O can be rolled.
2293 is_turnable <1> set if O can be turned 'automagically'
2294
2295 is_lightable <1> set if O is something like a lantern that can be lit
2296 is_used_up <1> bizarre. O is used up after created, eg an explosion.
2297 identified <1> true if the item has been identified.
2298 reflecting <1> set if O is reflective.
2299 changing <1> set if O will change appearance.
2300 splitting <1> set if O will divide.
2301 hitback <1> set if O hits when being hit.
2302
2303 blocksview <1> set if O blocks line of sight.
2304 undead <1> set if O is undead.
2305 scared <1> internal (O is running away from players right now)
2306 unaggressive <1> internal (not used yet)
2307
2308 reflect_missile <1> set if O throws back missiles.
2309 reflect_spell <1> set if O throws back spells (some).
2310 no_magic <1> set if O totally resists magic (*use with care*)
2311
2312 tear_down <1> set if O can be torn down (using animations and hp).
2313 run_away <no %> percentile of hp left which causes monster to flee.
2314
2315 pass_thru <1> set if O can be passed thru by objects <below>.
2316 can_pass_thru <1> set if O can pass thru objects <above>
2317 pick_up <value> Which items monster will pick up (see pickup (above))
2318
2319 is_buildable <1> set if items can be built on top of this O.
2320
2321 *******************************************************************************
2322 6. TREASURES (and Abilities)
2323 *******************************************************************************
2324
2325 The treasures are kept in LIBDIR/treasures. Their format is:
2326
2327 treasure <name>
2328 <item>
2329 more
2330 <item>
2331 end
2332
2333 Also, 'treasure' above can instead be 'treasureone'. This means
2334 that only 1 item on that list will be generated. The chance for
2335 all objects on that list are summed together, and one is then generated.
2336
2337 And the format for an item is:
2338
2339 arch <name>
2340 nrof <n (random 1 to n items generated)>
2341 magic <max-magic>
2342 chance <1-100%>
2343 yes
2344 <item>
2345 no
2346 <item>
2347 end (or "more", if this is not the last element)
2348
2349 If "magic" or "nrof" is omitted, it is set to 0.
2350 If "chance" is omitted, it is set to 100%.
2351 "yes" tells what can be generated if this item was generated.
2352 "no" tells what can be generated if this item was not generated.
2353 "yes" and "no" can of course be omitted.
2354
2355 Note: the 'no' and 'yes' fields are meaningless in treasureone
2356 treasurelists.
2357
2358 Also, instead of an item, a list to transfer to can be used instead.
2359 The format is the same as for an object, but instead 'list <list>' is
2360 used instead of 'arch <name>'.
2361
2362 For list transitions, the chance, yes and no fields have the
2363 same meaning. 'magic' is used to determine the difficulty required
2364 to transfer to the new list.
2365
2366 If the list is of type 'treasureone', and a list transition fails,
2367 what happens next is determined by the 'nrof' field. If it is zero,
2368 no object is generated. If 'nrof' is one, than another attempt is
2369 made to generate an item (or list transition) from that treasurelist. There
2370 is a maximum number of attempts that can be made.
2371
2372 Also, a reserved list name of 'NONE' is allowed. This means that no
2373 item should be generated (of relevance only on treasureone lists.)
2374
2375 To use such a treasure, just put "randomitem <name>" into any
2376 archetype in the archetype-file. Random treasure will then be generated
2377 whenever such a monster is generated by generator, or when a map
2378 containing such <monsters> is loaded for the first time.
2379
2380 ABILITIES
2381
2382 Adding in invisible objects like known spells and skills gives these abilities
2383 to the object.
2384
2385 for example:
2386
2387 treasure pirate
2388 arch skill_stealing
2389 chance 50
2390 arch skill_throwing
2391 no
2392 arch skill_punching
2393 end
2394 more
2395 arch heart
2396 chance 5
2397 more
2398 list standard
2399 end
2400
2401 or
2402
2403 treasure skeletalmage
2404 list standard_old
2405 more
2406 arch ability_fear
2407 more
2408 arch ability_frostbolt
2409 chance 67
2410 end
2411
2412 Treasure lists of gods are special. See below.
2413
2414 ------------------------------------------------------------------------------
2415 GOD INTERVENTION:
2416
2417 Treasure lists of gods are special. They must be of 'treasure' type,
2418 not 'treasureone', and the 'yes' and 'no' fields must not be used.
2419 The contents of a god's treasure list is not used by
2420 create_treasure(), but by god_intervention() which traverses this list
2421 from beginning to end until an item causes an action. The "chance" in
2422 the treasure list can be used to randomly skip items, but items that
2423 don't have an effect (e.g. healing follower, but follower isn't
2424 injured) will be skipped anyway. The meaning of the different items
2425 in the list is:
2426
2427 Treasure list reference:
2428
2429 Such a list is passed to create_treasure() with flag GT_STARTEQUIP.
2430 The generated treasure is put into the followers inventory. The
2431 follower can get unlimited amounts of this treasure just by praying
2432 long enough. See below ("other visible items") for an alternative
2433 way of giving items to followers.
2434
2435 Invisible books (with specific names):
2436
2437 Can be accessed through determine_holy_arch() which will return the
2438 item's other_arch field. For example, such book with name "avatar"
2439 determines the avatar archetype for the "summon avatar" prayer.
2440
2441 Invisible book with name "grace limit":
2442
2443 If follower doesn't have maximum grace, or follower's grace is less
2444 than item->stats.grace, a "holy possession" prayer is invoked and the
2445 function returns. Can be used to limit the lower part of the treasure
2446 list to followers with much grace.
2447
2448 Invisible book with name "restore grace":
2449
2450 If the follower's grace is negative, sets the grace to a small
2451 positive value and returns.
2452
2453 Invisible book with name "restore hitpoints":
2454
2455 If the follower's hitpoints are not at their maximum, sets hitpoints
2456 to maximum and returns.
2457
2458 Invisible book with name "restore spellpoints":
2459
2460 Can restore the followers spellpoints. The maximum spellpoints for
2461 this effect are calculated using this formula:
2462
2463 max = follower->stats.maxsp * (item->stats.maxsp / 100.0)
2464
2465 In other words, the item's stats.maxsp is the maximum in percent
2466 relative to the followers normal spellpoint maximum. If the followers
2467 current spellpoints are below 50% of 'max', they are set to a random
2468 value between 50% and 100% of 'max', and the function returns.
2469
2470 Invisible book with name "heal spell":
2471
2472 Casts a heal spell (which spell is determined by item's slaying or
2473 stats.sp field) and returns if the spell was successful.
2474
2475 Invisible book with name "remove curse":
2476
2477 Removes curse from all cursed (but not damned) items, returns if curse
2478 was removed from at least one item.
2479
2480 Invisible book with name "remove damnation":
2481
2482 Removes curse and damnation from all cursed or damned items, returns
2483 if curse or damnation was removed from at least one item.
2484
2485 Invisible book with name "heal depletion":
2486
2487 Removes all depletion effects and returns unless the follower's stats
2488 were not depleted.
2489
2490 Invisible book with name "voice_behind":
2491
2492 The follower hears a voice from behind. item->msg is what the voice
2493 says. Always returns.
2494
2495 Invisible book with name "message":
2496
2497 The follower receives item->msg as a simple message. Always returns.
2498
2499 Invisible book with name "enchant weapon":
2500
2501 The follower's weapon is enchanted in various ways. item->level
2502 affects how much the weapon is enchanted, higher value means less
2503 enchantment.
2504
2505 Invisible spellbooks:
2506
2507 If the prayer in the book is not yet known to the follower, and the
2508 follower has the required level, teaches the prayer to the follower
2509 and returns. The prayer is determined by item's slaying field.
2510
2511 Visible spellbooks:
2512
2513 If the prayer in the book is not yet known to the follower, the
2514 follower has the required level, and the follower doesn't already have
2515 a spellbook with that prayer, gives a copy of this spellbook to the
2516 follower and returns. The item must have FLAG_STARTEQUIP. The prayer
2517 is determined by item's slaying field.
2518
2519 Other visible items:
2520
2521 If the follower doesn't already have this or a similar item (with same
2522 type, name, title, msg and slaying fields), gives a copy of this item
2523 to the follower. You have to set FLAG_STARTEQUIP in the archetype
2524 yourself if you wan't the copy to have this flag. This method (with
2525 FLAG_STARTEQUIP set) should be preferred for giving items to followers,
2526 because it is rather safe to use. The amount is limited, because if
2527 the follower wants more of it he has to go back to an altar of his
2528 god. He can't pray an hour over an altar and then go fighting with a
2529 hundred potions of restoration.
2530
2531 Other invisible items:
2532
2533 If the follower doesn't already have it this item, gives it, similar
2534 to visible items. Except, it ALWAYS gives it, upon conversion.
2535 And on conversion to another religion, it is ALWAYS removed.
2536 Signs and forces and skills may not be given/taken this way.
2537
2538 ***************************************************************************************
2539 7. Misc change description:
2540 ***************************************************************************************
2541 The following area describes various comments about various pieces of
2542 code. In general, the information describes a basic idea of how things
2543 work. The following may not really be necessary, but I figure that it is
2544 probably worth saving, and this seemed to be as good as place as any.
2545
2546 LIGHTING CODE (by Brian Thomas):
2547 - fast calculation of lighting. For players los (line- of
2548 sight)is calculated from a linked list of nearby lights.
2549 For monsters, no los is calculated, rather a modified
2550 check_wakeup routine is used to see if they will
2551 follow/attack players. Monsters with can_see_in_dark act
2552 normally in dark areas.
2553
2554 - New attacktype -AT_BLIND. This is a pretty severe penalty
2555 for monsters and players alike. Players cant see any square
2556 but their own, monsters can only attack/follow players who
2557 are in an adjacent square. Need to make the monsters stumble
2558 around when no player is near, rather than the current way
2559 in which they stand around waiting to get "ace'd". Undead
2560 cannot be blinded, nor should be effected by darkness. For
2561 other monsters, if they have immunity to blindness or can
2562 see invisible, they are uneffected by AT_BLIND attacks.
2563
2564 - New spells. Some magician, some clerical. They work, but
2565 may need to be adjusted for playbalance. Normal spells
2566 available include: "light", "darkness", "sunspear", "faery
2567 fire" and "dark vision". All spells (but darkvision) work
2568 (do something) whether the lighting code is used or not.
2569
2570 - Modified archetypes and artifacts list to encompass changes
2571 to the code from lighting. Also, some new archs introduced,
2572 namely "flint and steel" for lighting stuff on fire and
2573 "torch" a source of light.
2574
2575
2576
2577 ***************************************************************************************
2578 8. How to add new values
2579 ***************************************************************************************
2580
2581 This section details how to add new fields/flags to an object structure.
2582
2583 1) Send mail to the development list to make sure that a new element is really
2584 added.
2585
2586 For flags:
2587
2588 2) Update the FLAG_.. entries in include/define.h for your new flag. Recycle unused
2589 values if possible - there may be cases where you want to group the new flags together.
2590 If you are adding beyond the end of the existing values, update the NUM_FLAGS entry
2591
2592 3) Decide the name of your flag as loaded/saved in objects. The default syntax is
2593 the name you assigned in step 2 above, minus the leading flag_ part.
2594
2595 4) In the common/loader.l, update the load section (where the code is mostly ^value
2596 SET_OR_CLEAR(...)) add your entries in.
2597
2598 5) update the flag_names in common/loader.l. The location of your names _must_ be
2599 in the same array location as the FLAG_ value.
2600
2601 6) Update other areas of the code that you presumably know about that will use these
2602 flag values.
2603
2604 7) As appropriate, update the arch files and rebuild.
2605
2606
2607 *******************************************************************************
2608 9. PROGRAMMING NOTES
2609 ********************************************************************************
2610
2611 This section provides some specific programming notes about objects. If
2612 you don't actually work with the C code, there is no need to read this section.
2613
2614 Almost all the char* pointers in the object structure use a shared string
2615 library. See Shared Strings below or on the wiki for more details.
2616
2617 When copying objects, the copy_object routine should always be used. It will
2618 add reference counts to the copied strings.
2619
2620 Shared string data should never be modified by any means - eg, strcpy(op->name,
2621 "new value") will update all the objects that use the same shared string as op
2622 does for its name.
2623
2624 Shared Strings
2625 ==============
2626
2627 Ref: http://wiki.metalforge.net/doku.php/dev:shared_strings
2628
2629 To minimize memory use, Crossfire uses a shared string mechanism. This is
2630 intended to be used for strings whose contents is not expected to change during
2631 the server's life. Using shared strings saves memory and improved performance.
2632
2633 Those strings are used like regular const char*, but should not be changed via
2634 strcpy, snprintf or other means because it would affect all structures using
2635 the shared string. Internally, they use a counter to track at how many places
2636 they are used. When it reaches 0, string is freed.
2637
2638 To alter such a string, the right behaviour is:
2639
2640 * write new value in a char[] new_value variable
2641 * use free_string(str)
2642 * call str = add_string(new_value)
2643
2644 FIXME replace with sstring when done in code
2645
2646 To manipulate them, the following functions (defined in common/shstr.c) are
2647 available:
2648
2649 * const char* add_string(const char *str), used to share a string. Returned
2650 value is a string with the same contents that can be shared with other
2651 objects
2652 * const char* add_refcount(const char *str), equivalent of add_string when
2653 the string is already a shared string
2654 * const char* find_string(const char *str), to search if a string is shared
2655 or not
2656 * void free_string(const char *str), to decrement the use counter. After
2657 it's called, str should not be used anymore.
2658
2659 Because shared strings will return a pointer to a string if it exists, one can
2660 see if the strings are equal by comparing the shared string address they point
2661 to (ie str == str2 directly).
2662