Creating Spells (3.5e Variant Rule)
From D&D Wiki
When a wizard prepares his spells he can make his own spell based on his knowledge of spells in general. He can then add that spell to his repertoire and prepare it again in the future. He makes a spellcraft check equal DC equal to 10 + 5 times the spell level. He can add +2 for every spell he knows that has something in common with the spell he is trying to create. For example, Fred the wizard, who has +5 in Spellcraft, wants to prepare a Ray of Fire instead of a Ray of Frost as a level 0 spell. The DC for creating this spell is 10, and he adds 7 to his roll, 5 for his normal spellcraft ranks, and 2 because he already knows a Ray of Frost spell. Any skill synergies for Knowledge (arcana) would also apply.
Alternatively, the DM can make this roll, and Fred would have to wait and try it out to see if it actually works. If he failed the roll, when he tries the spell it might fizzle, but if it fails horribly it might have adverse affects.
The idea is that a wizard can use his knowledge of the language of magic based on the spells he knows to dissect those spells into the parts that make up the effects of the spell. In the above example, Fred figures out what part of the Ray of Frost spell actually makes it a ray, and uses his general Spellcraft knowledge to figure out the fire part as well as assemble the spell. Any other ray spells or fire spells would make it easier to determine which parts do what. While this is very similar to researching spells not on the list of spells, it provide more flexibility on creating spells on the fly. This could be used when, say, a wizard knows he is going to be fighting a particular elemental and wants to have spells that would have the best effect. If a wizard has time to test the spell several times, tweaking it each time, then this check might be retried until a workable spell is found. Creating a spell would take at least as many hours spell level to create, so this is not necessarily something a party can do on a regular basis. If someone wants to hurry the process, they can take minuses to their roll equal to 2 times the number of hours skipped.
To figure out how powerful the created spell can be and what level it would be, follow the guideline about researching spells.