Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Adding new spells ...



> Hello,
>   I want to add a new type of spell (just to my local crossfire, I don't
> intend this to become part of the "standard" game), but I'm not sure
> exactly what needs to be changed.
> I've added it to the "spells" array in spellist.h, added one to
> NROFREALSPELLS in define.h, added an enum to spellnrs in spells.h,
> and I'm trying to work out how to change spells.c now.
> (I've also added an entry in LIB/spell_params).
> 
> The spell I'm trying to create is "Large Iceball" (an ice equivalent of
> large fireball) - is there some documentation on adding spells ? 
> (if not, there *should* be - changing 5 files to add 1 spell ! Sheesh)
> 

You're doing fine so far. Don't forget to add a line to SP_PARAMETERS in
spellist.h. In spells.c in the function cast_spell() (around about line 217)
there is a big switch statement that deals with every spell. Add your 
SP_L_ICEBALL in there (probably group it with the fireball spells as fire_arch()
should produce the effect you want). You will probably also have to add an
archetype like "icebullet" and "iceball" (to make things easier for yourself
make sure the types are FBULLET and FBALL). 

 The best way to do it is to walk through the code for a fireball spell and
understand how the spell effect is produced by the firebullet being created by
fire_arch(), how the firebullet object gets moved by apply(), and how it gets 
transformed in a fireball object and how the fireball expands in explosion().

 It is a bit confusing at first because objects are created by spells and their
effect occurs much later after the objects have 'acted', so you have to jump
around the code alot. Making a spell like Iceball is a good one to start with
as you can make it a variant of Fireball. IMHO archetypes are one the best 
features of Crossfire, they lead to so much generalization.


Rupert