Here's some of the botspellsai.cpp code:
Code:
// manacost has special values, -1 is no mana cost, -2 is instant cast (no mana)
int32 manaCost = mana_cost;
if (manaCost == -1)
manaCost = spells[AIspells[i].spellid].mana;
else if (manaCost == -2)
manaCost = 0;