ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/doc/Developers/spells
Revision: 1.2
Committed: Thu Sep 7 21:42:52 2006 UTC (17 years, 8 months ago) by pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
State: FILE REMOVED
Log Message:
Moved documents to doc/historic

File Contents

# Content
1 SPELLS:
2 ------------------------------------------------------------------------------
3 Index:
4
5 1. Background
6 2. Spell Objects
7 3. Spell Paths
8 4. Spell Subtypes
9 5. Spell Casting Objects
10 6. Arch Directory Layout
11 7. Programming Notes
12 8. Abilities
13
14 ------------------------------------------------------------------------------
15 1. BACKGROUND
16
17 This document describe all things spell and spell related that developers
18 need to know. This document outlines the new spell objects and how
19 this all works.
20
21 ------------------------------------------------------------------------------
22 2. SPELL OBJECTS
23
24 In the old model, each spell had a specific number associated with it.
25 Monster spell abilities, while objects, just said to use spell number
26 X. Given that everything else in the game is object, this hardcoding
27 of spells was less than ideal.
28
29 In the new system, spells are objects. The spell object the player knows
30 has the characteristics of the spell. As a first pass, the existing
31 spells are just converted to object form. As time passes, new spells
32 can be easily added in this system. It also simplifies the code - the
33 spells a player knows are now objects in his inventory. The spell
34 a wand casts is the spell in its inventory. The spell a scroll casts
35 is the spell in its inventory, and the spell you learn by reading
36 a spellbook is the spell in its inventory.
37
38 This model makes it very easy to make variations of some spells. Want
39 to make an extra large fireball? All this is needed is to take the
40 large fireball arch, increase a few parameters, and your all set.
41
42 The following is the fields in the object structure, and how they
43 correspond to a spell. Fields that are not mentioned are not used.
44
45 char *name: Name of the spell (large fireball, icestorm, etc)
46
47 char *lore: Description of the spell to be put in books, or perhaps even
48 to just let the player see. In a sense, this puts documentation of
49 the spells within the object, instead of having to maintain seperate
50 files.
51
52 sint16 casting_time : How long it takes to cast the spell (was time)
53 This is the number of ticks it takes for the player to cast the spell,
54 and is thus not a fixed time.
55
56 Suggested casting time values:
57 5: Combat spells (cones, bolts, balls, etc - ones you cast when in
58 danger)
59 10-15: Protection spells, other often cast spells. Summoning spells
60 would fall into this category, as they are often cast when not
61 in immediate danger.
62 ~25: Detection spells, or other spells done when times are safe.
63 Many ability improvement spells might fall into this category.
64
65 These are only suggestions - they more or less match when the spell will
66 be used and usefulness. An attack spell that takes forever to cast
67 isn't very useful. There are really two things to keep in mind - when
68 the spell is cast, and how long the spell itself last. A long lasting
69 spell can have a longer casting time, simply because it isn't cast
70 that often and will last for a while (thus, smart players won't cast
71 it in combat).
72
73 face/anim: If the spells is a generic spell that doesn't have an other_arch
74 pointer, this is the face (or animation to use when the spell is
75 cast.
76
77 uint8 type: SPELL (101) (to denote this is spell object)
78 sint16 resist[] values: For protection spells, resistance they provide.
79 uint32 attacktype: Attacktype of the spell.
80
81 uint32 path_*: spell path information. Note as of this writing, only
82 path_attuned is expected to mean anything. However, I can envision
83 the user of path_repelled/denied to denote that if the caster is
84 attuned to some path, they have penalties in casting this spell.
85
86 sint32 value: Base value of this spell for scroll, spellbooks, wands, rods.
87 sint16 level: Level of the spell
88
89 other_arch: archetype this spell uses. In the case of bolts, this
90 is the bolt that is fired.
91
92 char *skill (new): Skill needed to cast this spell.
93
94 sint32 subtype (new): Sub classification for this spell. It sort of
95 relates to the existing spell number, but in a more general form.
96 At first pass, subtypes would fall into protection spells, bolt
97 spells, ball spells, cone spells, stat increase spells. There
98 are a number of spells which can not be abstracted and are unique
99 in their own right (dimension door, word of recall, polymorph, etc).
100 In these cases, there will be one value for that spell type.
101
102 invisible: Always set to 1, so that the player can't directly see it in their
103 inventory.
104
105 no_drop: Always 1, so when a spell object is destroyed, the spell it
106 contains is dropped and not freed.
107
108
109 From living/stats substructure:
110 Str, Dex, etc: If spell changes and ability, this is the ability it changes.
111 sint16 dam: Base damage the spell does:
112 sint16 sp: how many spellpoints the spell costs
113 sint16 grace: how much grace the spell costs
114 sint16 maxsp/maxgrace: Every 'maxsp/maxgrace' levels beyond its base level,
115 the spell cost doubles (this is pro rated like the old code. For example,
116 if a first level spell costs 5 sp, and maxsp is 5, then at level 6 it
117 would cost 10 sp. However, at level 2, it is 6 sp, level 3 is 7 sp,
118 etc.
119 New fields added to object structure:
120
121 uint8 dam_modifier:
122 for every maxdam levels above what is needed to cast the spell, it does an
123 extra point of damage. Note if you want a spell to double its damage
124 every X levels, the maxdam may have to be quite low (1) if the spell does
125 high damage. For example, suppose you have a 10'th level spell that does
126 50 damage. If dam_modifier is 5, then every 5 levels it does one extra
127 point, so at level 25, it would do 53. If dam_modifier is 1, then at
128 level 25 it would do 65.
129
130 sint16 duration: Base duration of the spell (was bdur)
131 uint8 duration_modifier: Modifies duration of spell, acts the same way
132 as dam_modifier.
133
134 uint8 range: Range of the spell - this could be how far a lightning
135 bolt goes, how big that fireball is, etc. Spells with range 0
136 are personal only spells. Spells with range 1 can touch
137 a person on a neighboring space. range will not change based
138 on level of the caster - if higher range is desired, different
139 spell should be made.
140 uint8 range_modifier: Modifies range of spell, acts ame way as dam_modifier
141
142 TBD:
143 There are also many fields in the spell structure which are not
144 copied - charges, scrolls, scroll_chance, books, defensive,
145 cleric, onself.
146
147 The defensive, and onself can largely be derived from the
148 subtype above. if subtype is protection or healing, it'd be
149 self.
150
151 cleric is basically redundant now - the skill says what skill to use
152 for this spell. Note that a spell could in theory cost both mana
153 and grace - what it costs is not necessarily tied to a skill. However,
154 it would be bad practice to make a wizardry spell use mana. However,
155 I could potentially see hybrid skills that have some variosu benefits,
156 or if we have say a 'magic' god, perhaps some special spells it provides
157 a use mana.
158
159 So lets next touch on the idea of treasurelist for spell objects.
160
161 As mentioned above, spell objects, like wands, spellbooks, scrolls,
162 etc, contain the spell they cast. The way spells end up in those
163 objects is via a mechanism there is already code for - treasurelists.
164
165 Currently, the treasure generation code notices if a wand, rod, spellbook,
166 or scroll is generated. If so, it calls special code that looks
167 at the field of the spell structure and randomly chooses a spell.
168
169 Instead, this is just replaced with treasurelists. The scroll object
170 would have a 'randomitems scroll', wands a 'randomitems wand',etc. These
171 may be big treasure lists, but that shouldn't post any problem. More
172 likely, these lists would be broken up into smaller pieces (eg,
173 scroll_low_level, scroll_medium_level, scroll_high_level).
174
175 This provides finer resolution than is currently allowed in the spell
176 structure - you could make some spell available only in rods, but not
177 wands. you can better adjust things to better spells show up in
178 tougher dungeons, etc,
179
180 When a spell is cast, often it copies over certain values into the
181 SPELL_EFFECT (102). The subtype of the SPELL_EFFECT, which should generally
182 match that of SPELL itself, determines what the spell does.
183
184 ------------------------------------------------------------------------------
185 3. SPELL PATHS DOCUMENTATION
186
187 Long ago a number of archmages discovered patterns in the web that spells
188 weave in the aether. They found that some spells had structural similarities
189 to others and some of the mages took to studying particular groups of spells.
190 These mages found that by molding their thought patterns to match the patterns
191 of the spells they could better utilise all the spells of the group. Because
192 of their disciplined approach, the mages were described as following spell
193 Paths. As they attuned themselves to particular spell Paths they found that
194 they would become repelled from others, and in some cases found they were
195 denied any access to some paths. The legacy of these mages remains in some
196 of the magical items to be found around the world.
197
198 Technical details:
199 In the same way that players and objects can be protected, immune, and
200 vulnerable to the different types of attacks, they can now be attuned,
201 repelled, or denied access to the different spell Paths. An object that
202 is attuned to a Path cast spells from that Path at 80% of the spell point
203 cost and receives duration/damage bonuses as if the caster were five levels
204 higher. An object that is repelled from a Path casts spells from that Path
205 at 125% of the spell point cost and receives duration/damage bonuses as if
206 the caster were five levels lower (minimum of first level). An object that
207 is denied access to a Path cannot cast any spells from it. The casting
208 time is also modified by 80% and 125% respectively. These values are
209 defined in PATH_SP_MULT (from spells.h), PATH_TIME_MULT (from spells.h), and
210 path_level_mod (from spells.c)
211
212 The Paths themselves are the following:
213 "Nothing",
214 "Protection",
215 "Fire",
216 "Frost",
217 "Electricity",
218 "Missiles",
219 "Self",
220 "Summoning",
221 "Abjuration",
222 "Restoration",
223 "Detonation",
224 "Mind",
225 "Creation",
226 "Teleportation",
227 "Information",
228 "Transmutation",
229 "Transferrence".
230
231 See define.h for the number values corresponding to the Path.
232
233 Some more will be added in the near future. Some spells do not currently
234 belong to a Path, this is probably appropriate for some spells.
235 Paths are inherited just like protection/immunity/vulnerability, ie if a
236 ring contains "path_attuned 1", the wearer becomes attuned to the Path of
237 Protection.
238
239 Paths are quite powerful and shouldn't be given away cheaply. Ideally, most
240 objects with path_attuned attributes should have path_repelled and path_denied
241 attributes as well, to balance out (eg attuned to Fire, repelled from
242 Protection, and denied from Restoration)
243
244 ------------------------------------------------------------------------------
245 4. Spell Subtypes
246
247 This section lists specific spell subtypes and what they really
248 do. The idea is to try and generalize the object types (cones,
249 bolts, balls, etc). However, some number of spells, most notably
250 detection spells, must have their own entries because the code that
251 is actually executed needs to re-act accordingly.
252
253 SP_RAISE_DEAD (1)
254 These spells bring back dead players. These spells are only useful
255 on servers that use PERMADEATH.
256
257 Con: The number of con points the target character loses.
258 exp: the experience loss ratio (eg, exp -= exp/spell->stats.exp.
259 If zero, no exp is lost
260 last_heal: If set, corpse isn't required, just character name
261 randomitems: If set, then when the spell fails, the treasurelist is used
262 to determine what nasty monsters to summon. Note that this
263 list is not processed as a normal list - rather, everything
264 on the list is created, so chance values are meaningless.
265 race: If set, this is used as a treasurelist to determine what
266 class to change the character to (reincarnation). Basically,
267 it just looks up the treasurelist that is using the race name. This
268 should be a treasureone type list.
269
270 SP_RUNE (2)
271 Runes are objects that embed another spell in them, and are activated
272 when someone walks on top of the rune. Runes can be disarmed.
273
274 other_arch: This can be set to one of 3 values:
275 Name of rune (type = rune): If this is the case, rune is put on
276 the map with few changes.
277 name of spell: In this case, the spell is embedded into the the rune.
278 generic_rune object will be used, with the face updated.
279 NULL: in this case, the player specifies the rune to embed.
280 face: Face that the rune object will use.
281
282 If other_arch is set in the spell object, then it is assumed that
283 the sp (or grace) cost in the spell object is the total that should
284 be used. If it is an embedded spell, then the cost will be in
285 addition to that to cast the spell.
286
287 Special rules for runes where player can choose what spell to embed:
288 skill for the embedded spell must match the rune
289 Player must have enough mana/grace to embed the spell as well as cast
290 the actual rune.
291
292 Note that runes created by players/monsters will have the spell put into
293 the rune's inventory. However, archetype runes will still use the other
294 arch, as inventory in archetypes isn't really supported.
295
296 This really works fine - This allows custom spells to be embedded into
297 runes. For archetypes, using the default spell archetypes work fine.
298
299 SP_MAKE_MARK (3): This makes a 'mark' that contains a message. In the old
300 system, this used to be part of the rune code, but it really doesn't
301 have anything in common with runes (except in name).
302
303 other_arch: Object used to store the message.
304
305 SP_BOLT (4):
306 This fires a bolt (other_arch) of the spell object. All of the
307 following values are copied from the spell object and into the
308 bolt object (other_arch in the spell object).
309
310 damage, attacktype, slaying have normal meaning
311
312 range (exp): How many more spaces this will go before it ends.
313 duration (hp): How long it stays on each space.
314 Dex: chane (percentage) the bolt has of forking
315 Con: Chance that the bolt forks left.
316
317 Note if duration is less than range, which it should typically be,
318 then a bolt will only be in a subsection of the entire range.
319
320 A bolt object can have the generator flag set, in which case as
321 the bolt moves along, it will create an other_arch object. The
322 steambolt is an example of this. This can not be set in the spell object,
323 and is instead set in the other_arch field that the spell refers to.
324
325 SP_BULLET (5):
326 Bullets are single objects that go in a direction and hit
327 something. The simplest case here is magic bullet, that hits
328 something and does damage.
329
330 exploding ball type spells are a more complicated variation. These
331 object start out as a bullet, but when they hit something, they
332 explode, into fire or poison or the like. The other_arch field
333 determines what they explode into.
334
335 Values for spell object
336 range: diameter of the explosion (copied into maxhp).
337 Note that for the bullet itself, the range is always set to 50.
338 other_arch: bullet object to create.
339 dam: how much damage the bullet does.
340 attacktype: copied to the bullet.
341 slaying: copied to the bullet.
342 duration: How long the explosion lasts for. Not used for bullet
343 only spells. copied into hp field of the bullet object.
344 food (& dam adjust): Damage the explosion does. copied into the bullet
345 dam_modifier field.
346
347 See notes about explosion below.
348
349 SP_EXPLOSION (6):
350 Objects of subtype explosion are really only useful when attached
351 to a bullet - you don't really want to explode something on yourself.
352
353 Note that the set up of the below values is also the same for
354 SP_CONE types if a cone is attached to a bullet.
355
356 attacktype: from other_arch, but add magic if bullet has it.
357 damage: this is copied over the the bullet dam_modifier. The
358 bullet dam_modifier is based on the 'food' value
359 range: Copied over from stats.maxhp. This determines the radius of the
360 explosion.
361 duration: copied over from stats.hp. This determines how long the
362 explosion lingers.
363
364 Given two objects are created from one spell, tuning this/creating
365 new spells of this type is tricky. We can only use the range for
366 the bullet or explosion. Likewise, adjusting damage is difficult.
367 Ideally, perhaps, some additional fields in the spell object itself
368 are used to fully implement this, eg, these two fields determine the
369 range/damage of the bullet, and these 3 determine range/blast/damage
370 of the ball itself. That is the only real way to make a ball
371 spell fully adjustable.
372
373 SP_CONE (7):
374 sp is the overall direction of the cone is moving in.
375 other_arch: object to create as it moves along.
376 flag_lifesave: if true, object never goes away (eg, lava)
377 duration: This is how many ticks the spell stays on space.
378 flag_stand_still (was food): Causes the object not to progress
379
380 Note that SP_CONE can be the other_arch of a SP_BULLET. In this
381 case, the set up of the cone values is as described in SP_EXPLOSION
382 setting.
383
384 Note 2: The other_arch that is in the cone can really be any object.
385 As such, the code does not modify this object, other than to
386 set proper ownership. As such, you can't set what values will be
387 set in the arch thus created
388
389 vitriol is the best example of both of these notes - it starts out
390 as a bullet, which then turns into a cone, which then drops acid
391 pools.
392
393 SP_BOMB (8):
394 Bombs are as they are described - objects that sit around for
395 a little while before exploding.
396
397 The bomb itself is harmless - its not until it explodes do bad
398 things happen.
399
400 In the bomb object, the following attributes are set up:
401 dam: damage of the flying fragments/explosion
402 range: how far the fragments/explosion extends.
403 duration: How long the explosion lasts.
404 attacktype: Type of damage the bomb does.
405
406 bombs tick at a constant rate, as defined by there speed. They explode
407 when the finish their last animation. There is no way to adjust
408 this rate of ticking in the spell object, other than to point
409 other_arch at a customized bomb.
410
411 A bomb then explodes. It explodes into 'splints' (this is
412 unfortuantely hardcode), and the other_arch pointer of the bomb,
413 which default is of SP_EXPLOSION.
414
415 SP_WONDER(9):
416 wonder is a spell that will cast another spell. It will also sometimes
417 cast a cone of flowers (other_arch).
418
419 randomitems: treasure list to look for spell to cast.
420
421 Note old wonder code would only cast spell that would be found in
422 books. This new code can be used to cast most any spell, as defined
423 as in the treasurelist.
424
425 Note 2: Ideally, the flower effect should also be in this treasure list,
426 so the occurence could be accurately controlled.
427
428 SP_SMITE(10):
429 smite spells are target spells - the spell looks for an appropriate
430 enemy in the direction pointed, and if one is found, hits them with
431 whatever is in the other_arch. It is generally assumed that other_arch
432 will point to another spell.
433
434 other_arch: Object to create.
435 dam, range, duration (& modifiers) are copied into the spell effect
436 that other_arch points to.
437 attacktype: Attacktype to give to the spell effect.
438
439 Special notes if attacktype includes a death attacktype (finger
440 of death):
441 Won't work on undead - makes them strong.
442 the level of the created object is set to the dam (& modifier)
443 of the spell.
444
445
446 SP_MAGIC_MISSILE(11):
447 magic missiles are really just a bullet type object that have
448 some more intelligence in their guiding (but not much). Basically,
449 a magic missile will more or less go in the direction it is fired,
450 but will adjust course to hit a monster. Thus, if something isn't
451 perfectly lined up, magic missile will still hit it.
452 range, attacktype, etc, all have normal meanings.
453
454
455 SP_SUMMON_GOLEM(12):
456 This spell summons a friendly creature/object that helps out the
457 player.
458
459 other_arch: Pet/object this spell creates.
460 race: If set to 'holy servant' or 'avatar', this is now a
461 summon avatar spell, whose monster is determined based on the
462 god being worshipped. Note that these names are just passed
463 to determine_holy_arch()
464 dam: How much damage the golem will do. dam_modifier alters this in the
465 expected way. If zero, damage from the golem is used, but damage
466 modifer will still be added.
467 duration: increases the golems hp, which basically amounts to duration.
468 attacktype: If set, golem gets this attacktype instead of the
469 normal arch attacktype.
470 range_modifier: This adjust the wc and speed of the creature.
471
472 golems lose 1 hp each time they do something. This effectively
473 limits their duration, but does mean it can be extended by healing
474 the golem. Not sure if this is the way to go, or if duration
475 should really just be used.
476
477 Note - the old code had ldam and ldur have multiple meanings, and
478 the code multipled them by 10 internally. This is no longer done -
479 instead, the archetype itself should have the real value (10 times
480 the old compiled in values)
481
482 SP_DIMENSION_DOOR(13):
483 dimension door lets the player move some large number of spaces.
484 One still can not teleport through no magic areas.
485 range: How far we will move the player
486 maxsp, level_modifier: Normal spell meaning.
487
488 SP_MAGIC_MAPPING(14):
489 This draws an overview of the map around the player. There are currently
490 no parameters the spell takes - the results are always the same. One could
491 forsee parameters to change how far one sees, what one sees, etc.
492
493 SP_MAGIC_WALL(15):
494 This spell creates a magic wall. Walls can have a wide set of
495 properties. Many are determined by the other_arch or race (the wall
496 the spell creates).
497
498 other_arch: wall to create.
499
500 race: Name of the object to summon. This should include the %d.
501 eg, 'director_%d'. Note that if the object is non directional,
502 just don't include the %d in the race. Note that if both other_arch
503 and race is set, then other_arch takes precedence
504
505 no_pass: If set, then the object can not be created on the space the
506 player is standing on. In all cases, the object can not be
507 created on a space that is blocked by an object.
508
509 is_used_up: If set, then this flag is set in the created object
510
511 tear_down: If set, this flag is then set in created object, as well
512 as flag_alive
513
514 range (and range_modifier): How many spaces in each direction the wall
515 should go. If this is 1, the wall will be 3 spaces total (1 + 1 in
516 each direction). If this is 0, the wall is a single space.
517
518 attacktype: Attacktype to set on the created wall.
519 duration (and duration_modifier): The number of hit points/duration
520 of the wall.
521 dam and dam_modifier: Damage the wall does.
522
523 Exactly how the a attacktype, duration, and damage values play out
524 depend on what is being created and the spell.
525
526 Created object is of type SPELL_EFFECT: attacktype, dam, and duration
527 are copied into fields of same name.
528
529 Created object is alive: duration becomes the objects hit points.
530
531 is_used_up (either in spell, or created object): duration put
532 into objects food value.
533
534 tear_down (in spell only): Spells damage value is copied into
535 objects hp/maxhp
536
537 The level of the created object is always set to half that of
538 the caster level.
539
540 SP_DESTRUCTION(16):
541 Destruction hits all the spaces within some distance of the player
542 with damage.
543
544 range (& modifier): Number of spaces in each direction to do damage to.
545 dam (& modifier): Amount of damage to do to each creature.
546 attacktype: Attacktype to hit the creatures with.
547 other_arch: This can in practice be anything, but is typically just used
548 as an effect to show what spaces where hit.
549 race
550
551 Note: As converted to a spell object, this is now usuable by monsters.
552 The rule for what is damaged is basically this:
553 If cast by a player/friendly creature, damages non players/non friendlies.
554 If cast by a monster (non friendly), damages players/friendlies.
555
556 SP_PERCEIVE_SELF(17):
557 This is really just a hook to know to call the right routine - at
558 current time, none of the dam/range/duration fields of the spell
559 have any meaning - only think that is used is the grace and skill
560 pointers.
561 perceive self basically presents information to the player about themselves,
562 eg, race, any depletions, etc. Generally, isn't that useful since most
563 all the same information is available with built in commands.
564
565 SP_WORD_OF_RECALL(18)
566 Word of recall teleports the player back 'home' after some amount
567 of time. Parameters:
568 duration: How many ticks until the player is returned hom.
569 duration_modifier: This _reduces_ the duration above so that the player
570 return home quicker.
571
572
573 SP_INVISIBLE(19):
574 Makes the character invisible to monsters.
575 duration (& duration_modifier): How long to be invisible for.
576 race: What to make the player invisible against. Note this
577 only applies for when players cast invisible - monsters
578 will always be invisible to players, and not care about
579 the race field. race 'undead' has a bit special meaning,
580 as it will chack against the flag_undead field. race can
581 be NULL, in which case it will make the player invisible
582 to everything _but_ undead. Note also that check is done that
583 'race' a subset of the race of the monster (eg, don't use
584 comma seperated values).
585 It is not possible to be invisible to both undead and non
586 undead at the same time.
587 make_invisible: if set, this is 'improved' invisible vs temporary
588 invisibility that disappears when attacking.
589
590 SP_PROBE (20): This spell looks in some direction (as specified by the player)
591 and returns information about a monster.
592 range (& modifier): How far off in a direction to look.
593
594 SP_HEALING(21): This spell heals a character/monster. Creature must
595 be where the player is.
596 attacktype: Attacktypes to heal:
597 AT_DISEASE: cure diseases.
598 AT_POISON: remove poisoning.
599 AT_CONFUSION: remove confusion.
600 AT_BLIND: remove blindness
601 stats.food: Food amount to add to character.
602 stats.dam: how much to heal.
603 stats.hp: Number of d6 to roll for healing.
604 last_sp: Regenerate this number of spell points.
605 last_grace: Regenerate this number of grace points.
606 (since the sp and grace fields are used for how much it costs
607 to use the spell, we can't re-use those fields unfortuantely)
608 other_arch: seems unused - kept could be used as a spell effect
609 indicator.
610 Note that any number of these fields can be combined.
611
612 SP_CREATE_FOOD(22): This creats food for the player. The food is
613 not worth any money, but otherwise normal food.
614 food: Base amount of food to create.
615 duration_modifier: Creates an addition 50 food/increase of this value.
616
617 The formula for how much food value is created is:
618 food_value=spell_ob->stats.food +
619 + 50 * SP_level_duration_adjust(caster,spell_ob);
620
621 SP_EARTH_TO_DUST(23): This destroys earthwalls near the player.
622 range (& modifier): Radius to destroy earthwalls in. Note that
623 this is a 'square' radius.
624
625 SP_CHANGE_ABILITY(24): this adjust some ability the player has (str,
626 dex, attacktypes, etc). This is only for beneficial effects - this
627 is mostly because of the targetting logic (negative effect would
628 still target friendly creature).
629
630 By default, only one benefit spell of each time can be active at a
631 time (eg, you could have a strength and a dex, but not two strength
632 spells). This is noormally tracked by changing the force name to
633 be the same name as the spell, but see the race attribute below.
634
635 If a spell is already in effect, the duration of the existing
636 spell will be increased, but otherwise none of the spell effects
637 will be changed.
638
639 race: If this is set, this is used instead of the spell name when
640 renaming the force. This is useful if you only want one of a group
641 of spells active at once (this is currently used for bless &
642 holy possession - you're allowed only one.) name_pl of the force
643 will always contain the other spell name.
644
645 duration (& modifier): How long the spell lasts for. Note that duration
646 is in ticks. Note old system used damage for duration, and each
647 point of damage was basically 50 ticks. Note also that duration_modifier
648 is a bit difference - this increases durations in 50 ticks - this
649 is because most of these spells are long duration, and increasing
650 a 200 duration spell by 15 ticks if the caster is really high
651 level is pretty meaningless.
652
653 resist_*: The protection the spell grants. Note that the code does
654 no sanity checking on these values, other than to make sure they
655 do not exceed 100. Before spell objects, there was code to put
656 caps on these values. There is no practical way to say waht the
657 caps should be if so put on - instead, just make sure that
658 that dam_modifier is a sane value.
659
660 dam_modifier: Increases the resistance granted by 1 point.
661
662 ac: Benefit to armor class. This is copied over unmodified.
663 wc: Benefit to weapon class. This is copied over unmodified
664 hp: Copied over, but damage adjustment added as a bonus. hp
665 in the form of a force increases characters hp regen rate.
666
667 Str, Dex, Con, Wis, Int, Pow, Cha: Attempted adjustement to the
668 stat. These values are number of d3's rolled to adjust. In
669 additin, these values also determine the max benefit based on the
670 recipient - the table is 15 + 5 * attr_value. If 1, then the
671 highest the recipients stat after this would be 20. If 2, highest
672 would be 25, if 3, highest would be 30, etc.
673
674 flying, can_see_in_dark, xrays: Copied over to force -
675 gives caster this ability.
676
677 attacktype: Added to force object, giving the caster the attacktype.
678
679 exp: Copied over - this acts as bonus speed. This value is adjusted
680 so really fast players get less a benefit than slower players.
681
682 SP_BLESS(25):
683 This blesses the character - the character gets various benefits
684 based on the god he worships. Note that BLESS spells use the same
685 type of force object as ability change above, include the race
686 to prevent multiple castings. Note that most of all of the values
687 are copied _from the god_. The value in the spell_object is only
688 really used to know if the value from the god should be copied.
689
690
691 resist_godpower: The character gets the resistance benefits that his
692 god gives (which can be anything). resist_godpower is the upper limit
693 of any benefit the character will get.
694
695 last_grace: If set, players get same attunement as their god.
696
697 attacktype: If non zero, the player gets the attacktype of the god.
698 The character also gets the slaying of the god if attacktype is set.
699
700 ac, wc: Copied over from spell_ob to force.
701
702 SP_CURSE(26):
703 This is a lot like BLESS. Notable difference is that this is a bad
704 effect for the recipient.
705
706 ac,wc: Copied over from spell_ob - should be negative, since these
707 should be penalties.
708
709 last_grace: If set, recipient is denied/repelled to spellpath that the
710 god is denied/repelled with.
711
712 race: Same as for SP_BLESS, in that it can be used to limit number
713 of course type effects.
714
715 range: Range of the spell.
716
717 SP_SUMMON_MONSTER (27):
718 This covers a large subtype of monster/object summoning. At its
719 very basic, this spell will create an object that is unchanged
720 from the archetype, and thus can be used to basically create any object.
721
722 other_arch: Object to create.
723
724 randomitems: If set, a treasurelist to use to select the monster from.
725 The randomitems list for these spells is a bit special - the magic
726 entry is what the monsters effective level is. One can not summon
727 monsters of higher level than they are. Note that magic values
728 should be unique, as the list will use the highest value available.
729 So if two identical magic values are used, for different objects,
730 only the second entry would actually have monsters created.
731 In addition, the magic values should be in order.
732
733 race: If set to "GODCULTMON", this is a special spell that will
734 create monsters associated with the players god. We can't use
735 either of the two fields to denote this, because they point to
736 other structures, and what monsters we should create can not be
737 defined easily in the archs, as it will depend on what god the player
738 worships.
739
740 If multiple fields above are set, the order used is other_arch,
741 random_items, race. Only one of the values will be used - you can't
742 get multiple things created by setting up multiple values.
743
744 attack_movement (move_type): If set, this is set in the monster. Thus, if
745 the object should be a pet, move_type should be set to PET_MOVE.
746
747 dam (& modifier): Number of creatures to create. In the case of
748 spells that use randomitems (which can specify their own nrof), this
749 is acted as additional monsters.
750
751 flag_monster: If set, creature will not be friendly. If cleared,
752 flag_friendly will be set on the monster (using the flag_friendly
753 in the spell_ob itself is problematic in that there is a special
754 list for friendly objects, and we really don't want the spell on that
755 list.
756 The reason not all summoned monsters are friendly is because there are
757 some spells that create monsters specifically meant to be agressive
758 to the player.
759 If flag_monster is set, the monster/created object is not changed.
760 Only if it is not set, do we set a value (flag_friendly).
761
762 SP_RECHARGE (28):
763 This spell is used to recharge a wand.
764
765 dam (& modifier): Number of 'spell levels' to recharge. Basically,
766 the number of charges increase in the wand by dam / wand spell level.
767 Thus, very low level wands are easier to recharge than high
768 level wands.
769
770 SP_POLYMORPH (29):
771 This spell by default is disabled because of variosu abuses within
772 the spell.
773
774 The spell normally turns one object into another similar type of
775 object (eg, orc to goblin, sword to dagger, etc).
776
777 range (& modifier) How far the polymorph spell extends.
778 other_arch: Visual effect to draw on the map as it moves along.
779
780 SP_ALCHEMY (30)
781 This turns nearby objects into gold nuggets.
782
783 duration (& modifier): This is multiplied by 1000 to determine the
784 amount of material that will be converted (think of these values
785 as the amount of kilograms to be converted)
786
787 SP_REMOVE_CURSE (31)
788 This removes the cursed/damned status of objects. It only
789 effects objects equipped by the player.
790
791 cursed: uncurse cursed objects.
792 damned: remove damnation.
793
794 SP_IDENTIFY(32)
795 This identifies objects in the players inventory and on the ground.
796 dam (& modifier): The number of objects to identify
797
798 SP_DETECTION(33)
799 This detects nearby objects (including ones in the players inventory).
800 Detection in this context typically means revealing properties about
801 the objects.
802
803 range (& modifier): How big a radius to look for objects. Radius
804 in this context is really a square - the size of the square would
805 be 2*range + 1, with the player being in the center.
806
807 other_arch: The spell effect to draw on the map for spaces that match
808 the object. Note that for some detection types, the face is replaced
809 by the face of the matching object.
810
811 This following attributes determine what objects to show. Note that
812 more than one of these can be set (for a 'detect all spell' for example).
813
814 make_invisible: If true, show invisible objects
815 known_magical: If set, detect magical objects.
816 flag_monster: If set, detect monsters
817 known_cursed: If set, detects cursed objects.
818 race: If set, only detects creatures of this race. if race is
819 'GOD', then it uses the god's slaying race for the match.
820
821 SP_MOOD_CHANGE (34):
822 This changes the 'mood' of a monster. See below for how moods are
823 changed.
824
825 range (& modifier): How for this spell effects, just like SP_DETECT above.
826 race: If set, only monsters of matching race are effected. Can be set
827 to GOD_SLAYING, in which enemy races of the god are effected.
828 if set to GOD_FRIEND, then races alligned with the god are effected.
829 attacktype: Attacktype the spell hits with. The spell doesn't do any
830 damage - this instead is used for saving throw information. Note
831 that the monster uses its best resistance for the saving throw.
832 EG, the more attacktype the spell has, the better the odds.
833
834 berserk (flag): Set the monster to be berserk, which basically means
835 it attacks anything (conflict spell)
836 unaggressive (flag): Sets the monster to be unaggressive. (pacify)
837 undead (flag): By default, undead are immune to mood changes. however, if
838 this flag is set, undead will be effected (limited by other criteria
839 above, like race (if set) and saving throw)
840 no_attack (flag): Make the creature friendly (charm & charm monster))
841 monster (flag): Wakes the monster up, makes it an enemy of the player
842 (aggravation)
843
844 Note that a spell could set multiple of these fields, but it wouldn't
845 really do much - a monster can really only have one mood.
846
847 SP_MOVING_BALL (35): This is really only used as a spell effect. Values
848 of note:
849
850 path_repelled: If set, the player must be attuned to these paths
851 to cast the spell. This can basically be used to control
852 who can cast the spell.
853
854 duration (& modifier): Copied into food of the object - this is
855 basically how long the spell lasts for.
856 dam & attacktype have expected meaning.
857 other_arch: Object that is used for the manifestation of the spell.
858 Must be set for spell to work.
859
860 SP_SWARM (36)
861 swarms are spells that fire other spells. It fires the same spell,
862 but multiple times (eg, 5 lightning bolts).
863
864 Set during casting:
865 duration: Number of d3 to roll to determine number of sub bolts.
866 duration_modifier: Added to duration as a bonus.
867 other_arch: Name of the other spell it fires.
868
869 SP_CHANGE_MANA (37)
870 This gives/takes spellpoints to the target of the spell. If this spell
871 gives sp, the the cost should be more than the sp it gives. target must
872 be in the same or adjacent space.
873
874 dam (& modifier): number of sp to transfer. If dam is negative, then this
875 spell takes away, and dam and modifier represent what percentage of sp
876 to drain (dam_modifier should still be positive). These sp are then
877 given to the caster of the spell.
878
879 This subtypes corresponds to the old transferrence and drain magic
880 spells.
881
882 SP_DISPEL_RUNE (38)
883 This removes runes from the ground. There are currently no
884 tunables for this spell.
885
886 SP_CREATE_MISSILE (39)
887 Creates bolts or arrows.
888
889 dam (& modifier): max plus of arrow that can be created.
890 duration (& modifier): Number of arrows to create.
891
892 Note that making good (highly magical) arrows reduces
893 number of arrows to be made.
894
895 SP_CONSECRATE (40)
896 This converts an altar to that of players god. There are currently
897 no tunables to this spell.
898
899 SP_ANIMATE_WEAPON (41)
900 This spell is similar to the GOLEM spells - it basically creates
901 a golem, but uses a donor weapon for the face, basic attributes,
902 etc. To implement this, it puts the donor weapon in the inventory
903 of the golem, so when the golem dies, the weapon is returned
904 to the ground. Note that in the conversion, I modified this
905 spell to use the weapon 'marked' by the player, instead of the
906 equipped weapon.
907
908 other_arch: The object used to encapsulate the weapon.
909 race: If set, the donor weapon must match this name. If this is not
910 set, then the face of the golem will be set to the weapon.
911 The reason for this is that if race is set, then since it
912 is matching a specific weapon, it is presumed that the
913 other_arch field can be appropriate set.
914 range_adjust: Bonus to wc and speed for the spell
915 duration & modifier: Bonus to creatures hp.
916 dam & modifer: Adjust to damage the golem does.
917
918 SP_LIGHT (42)
919 Arguably, such a basic spell wouldn't seem to need its own subtype.
920 However, looking at the other spells, it really didn't fit in
921 very well elsewhere - the magic_wall code passes most of its
922 parameters to the object it creates. Something like summon_monster
923 doesn't work, because it wants a free space to put the object.
924 And while it would be nice to somehow merge create food, create
925 missile, and this, they are sufficiently different that they don't
926 work very well. So instead, I try to abstract this as much
927 as I can.
928
929 attacktype: If set, and there is a monster on the target
930 space, the monster gets hit with the attacktype and the
931 damage setting. If this happens, the spell progresses no
932 further.
933 dam: As per note above, how much damage this does.
934
935 other_arch: Object to place on the map.
936 duration: set the the 'food' value in the created object -
937 if is_used_up is set in the arch, this is how long the
938 spell lasts for.
939 range: If the created object has a glow radius, range
940 is used to replace it. In this way, we don't make non
941 glowing objects glow, but do make ones that do glow
942 glow brighter.
943
944 SP_CHANGE_MAP_LIGHT (43)
945 This changes the light level on the map. There is only one
946 tunable:
947
948 dam: amount to change the lightlevel. This is passed to
949 change_map_light, as such, negative values are lighter,
950 positive is darker
951
952 SP_FAERY_FIRE (44)
953 Faery fire makes creatures within the area of effect glow.
954 This code uses the cast_destruction routine, but just handles
955 what happens when it finds a valid target.
956
957 range (& modifier): Number of spaces in each direction to do damage to.
958 duration & modifier: Potency of the spell - determines how long the
959 creature will glow for (in 10's of ticks)
960 other_arch: This can in practice be anything, but is typically just used
961 as an effect to show what spaces where hit.
962
963 Note: As converted to a spell object, this is now usuable by monsters.
964 The rule for what is damaged is basically this:
965 If cast by a player/friendly creature, damages non players/non friendlies.
966 If cast by a monster (non friendly), damages players/friendlies.
967
968 SP_DISEASE (45)
969 disease spells infect players with a harmful disease.
970
971 range (& modifier): How far to look in the line for matching
972 targets.
973 other_arch: Disease to infect the target with.
974 duration_modifier: This is used to adjust the disease stats
975 in several ways:
976 wc += mod/2
977 magic += mod / 4
978 maxhp, maxgrace += mod
979
980 dam_modifier: Modifiers other aspects of the disease:
981 dam, maxsp, ac, last_eat, hp, sp: modified by full mod
982 last_sp: modifier by mod * 2
983
984 The disease code treats these modified values in its own way.
985
986
987 SP_AURA (46):
988 Auras create fields around the players that effect anyone that steps
989 into them.
990
991 other_arch: aura type to insert
992 duration: How long the aura lasts for. For this spell, each
993 duration_modifier is 10 ticks.
994 dam & modifier: How much damage the aura does.
995 attacktype: Attacktype of the aura.
996
997 SP_TOWN_PORTAL (47):
998 This creates two linked portals which the player can use to get
999 back and forth quickly.
1000
1001 other_arch: Name of the force object to use to mark the first portal
1002 target location (town_portal).
1003 race: Name of the object used to mark where the portals goe
1004 (town_portal_active)
1005 slaying: Name of the object used for the actual exit objects
1006 (town_portal_magic)
1007
1008 Note the spell otherwise doesn't have any tunables.
1009 It should be noted that if different archetypes were made it,
1010 it should be possible to have multiple town portal type spells that
1011 lead to different destinations.
1012
1013
1014 Old values:
1015 hp: duration
1016 exp: range
1017 maxhp: set to a ->count variable, so spells can be uniquely identified.
1018
1019 ------------------------------------------------------------------------------
1020 5. Spell Casting Objects
1021
1022 As described in section 2 above, objects that cast spells (wands, rods,
1023 scrolls, etc) contain the spell they cast in their inventory. When the player
1024 uses the object, the code looks for an object in the inventory, and uses that
1025 as the type of spell to cast.
1026
1027 Treasure lists are used to determine what spell goes in the object. Thus,
1028 what spells show up in the objects is determined purely by the treasure lists,
1029 and unique lists can be pade for potions, scrolls, wands, horns, and even
1030 different lists for heavy and light rods.
1031
1032 The value of the finished object is the value field in the spell object
1033 multiplied by the value object in the original object (rod, wand, scroll).
1034
1035 For items that come in different levels, the value is also adjusted based on
1036 the level of the object based on the difference of level. The
1037 code for this is in common/treasure.c
1038
1039 The nrof field for the treasurelists for these objects have special meanings -
1040 since the spell objects are invisible objects within the spell casting object,
1041 the nrof field has no actual meaning. However, we borrow that meaning for use
1042 in the parent object.
1043
1044 For wands, nrof is used for the number of charges the item has.
1045 For scrolls, nrof is the number of scrolls to make. This overrides the
1046 nrof value for the scroll itself - this allows for fine tuning number
1047 of scrolls that show up for different spells.
1048
1049 RODS/HORNS:
1050 ----------
1051 hp is the amount of 'energy' the rod currently has. when a spell is
1052 cast, hp is reduced by the amount of sp/grace the spell takes up.
1053 speed: how often the rod recharges. There used to be a much more complicated
1054 way of of regenerating charges. Instead, each time a rod activates,
1055 it regenerates 10% of its total power. Thus, a rod of speed 1.0 would
1056 fully recharge in 10 ticks, a rod with speed 0.1 would fully recharge in 100
1057 ticks.
1058
1059 This change in the way rods recharge now mean the speed of a rod can
1060 be set in a map (or elsewhere), and that change would stick.
1061
1062 Within the archetype itself, the maxhp value determines the number of
1063 spells the rod can hold before it needs to recharge again.
1064
1065 POTIONS/DUSTS:
1066 --------------
1067 potions and dusts (which were really just potions with a is_dust flag set)
1068 have been redone in several ways.
1069
1070 First, potions had varying meanings for the same archetype. You could
1071 have potions that improve stats permenantly, ones that cast spells,
1072 and dust.
1073
1074
1075 There is now a SPELL_POTION (116) type. This is used for potions that
1076 ast spells. These type of potions really never should have been the
1077 same type in the first place - other than name, they really had
1078 none of the same code.
1079
1080
1081 FIREWALL (62)
1082 ----------------------------
1083 These objects are very basic - they cast a spell whenever they activate.
1084 If they have a spell object in their inventory
1085 (must be first item), that is the spell that is cast. Otherwise, they
1086 cast what other_arch points to.
1087
1088 Firewalls can be activated by buttons, and can also cast spells in specific
1089 directions. The direction the firewalls fire in is stored in the 'sp' field
1090 of the firewall.
1091
1092 Note that FIRECHEST (61) got folded into FIREWALLS, because functionally,
1093 they were identical - just set 'sp 0' in the firechest, and it fires
1094 in a random direction.
1095
1096 ------------------------------------------------------------------------------
1097 6. Arch Directory Layout
1098
1099 This section describes the basic layout of the archetypes in the arch
1100 directory. This explanation is here to try and prevent confusion (where
1101 should this arch go), where would I find an arch, etc.
1102
1103 I thought about this a bit - would it be better to organize spells by
1104 attacktype (eg, all fire spells together, all cold spells, etc), or by type of
1105 spell (bolt spells, bullet spells, cone spells, etc).
1106
1107 I think both methods have valid reasons for and against them. I decided to do
1108 it by spell type because I think it will make it easier to compare spells.
1109
1110 For example, if one bolt spell does 20 damage, and another does 30 damage,
1111 even if by another attacktype, pretty easy to see that the later is more
1112 potent.
1113
1114 This also organizes the spells more by their subtype, which is the more
1115 standard way the arch's have been done in the past. It makes for designing
1116 new spells much easier (you'd just copy a starter arch from the same
1117 directory, and not need to hunt for another one - imagine something like
1118 acid bolt).
1119
1120 That said, the organization (all relative to the arch top level directory)
1121
1122 magic: This directory goes away. There are many things that are magical
1123 that are not spells, so having a directory named magic is IMO not the
1124 best of name:
1125
1126 spell: top level directory. This directory is for the spell archetypes,
1127 and is not meant to contain non related spell code. thus, the
1128 pentagram (actually a teleporter), and the weapon improver scrolls
1129 (not really in any way related to spells) would get relocated.
1130
1131 Bolt: Contains the bolt spells
1132 Bullet: Bullet spells.
1133 Common: Contains objects that are related to spells in many areas,
1134 eg, the burnout is used by many types of spells, and things like
1135 a flaming square or icy square are used for cone, bolt, and
1136 exploding ball spells - those would be located here.
1137 Cone: Contains cone spells
1138 Healing: healing spells
1139 Potions: Contain the various potions.
1140 SeekingBall: spells like ball lightning
1141 Spellbook: spellbook/prayerbook objects.
1142 Wand: Contain the wand, staff, rod archetypes.
1143
1144 There are almost certainly sub types I'm missing that I'll have to fill in.
1145 The idea here is to try to sketch something out that gives me a working
1146 layout to fill things in.
1147
1148 Within each of the spell subtype directories, the entries for the spell
1149 information would be needed. And example below:
1150
1151 spell_lightning_bolt.arc: This is the spell object that goes in the player/
1152 monster inventory that says they know the lightning bolt spell. As
1153 per other documentation, this also contains things like the skill needed
1154 to use this spell, spell point cost, level cost, etc.
1155
1156 lightning_bolt.arc: this is the other_arch of the spell_lightning_bolt.arc.
1157 Few values in this are actually used - most of the values come from
1158 the parent arc. However, this (lightning_bolt.arc) contains the
1159 information like what the animation for the spell look like.
1160
1161 lightning_bolt.base.111.png (and so on) are the images used by the
1162 lightning_bolt.arc arch.
1163
1164 In the case of subtype directories with lots of entries, it is likely that the
1165 directories may then get broken up by things like attacktype of the spells.
1166
1167 ------------------------------------------------------------------------------
1168 7. PROGRAMMING NOTES
1169
1170 The number of top level object types is reduced - instead, many are now
1171 SPELL_EFFECT, with the subtype being the same as the spell that created
1172 them.
1173
1174 The server/time.c still has a dispatch for the SPELL_EFFECT, but it
1175 is in server/spell_util.c which determines how each subtype should
1176 be handled.
1177
1178 I try to keep all the same spell related code together, eg, put the
1179 code that casts the cone as well as moves the cone in the same file
1180 next to each other. This should reduce bugs - if someone changes
1181 one piece, they are more likely to notice the other piece and also update
1182 that. This is better than having the function in a completely different
1183 file.
1184
1185 spell_util.c really only contains very general code - dispatch routines,
1186 funcitons to adjust spells, etc. The actual work is done in either
1187 spell_attack.c, spell_effect.c, rune.c, or pets.c.
1188
1189 basically all the defines are in include/spells.h. This is a much simpler
1190 file than once was here. Remember, all the data now comes from the
1191 archetypes.
1192
1193 ------------------------------------------------------------------------------
1194 8. ABILITIES
1195
1196 In the old code, abilities had some special meaning in terms of what
1197 spells the monster would cast.
1198
1199 In the new system, abilities are no different than spells, and use the
1200 same type/subtype.
1201
1202 Abilities may still be seperate for a few reasons: 1) monsters are not
1203 likely to have all the needed skills. 2) sp/grace costs may be
1204 different. 3) Many abilities shouldn't add attacktype magic. 4) Abilities
1205 generally have a very fast casting time, since monsters move slower.
1206
1207 It should be noted that many creatures just use the spell, and not
1208 the ability. Only some spells have ability counterparts.
1209
1210 Note: Before giving spell abilities to monsters, be sure that the monster
1211 will actually use them - the code in monster.c results in monsters only
1212 casting spells of certain subtypes.
1213
1214 maxsp: This increased the likelihood of monster choosing the spell.
1215 (eg, maxsp 3 vs maxsp 1 would mean 3 times as likely). This should
1216 instead by done in the treasurelist, so that more of that ability
1217 is created.
1218
1219 hp/sp: Index for the spell that is used. One was 'short' range vs
1220 long range.