It uses the spell data of the spell based on an MQ2 TLO. I "borrowed" the code years ago, so it could have changed, but it pulls it directly from the spell struct.
This is a simplified snippet to see if a spell is ready to cast. There are other checks as well. Distance is the final check. This is mostly just the distance check code. A separate part of code calculates the distance to the mob.
[CODE lang="cpp" title="IsSpellReady()" highlight="3"]PSPELL spell=GetSpellByID(spellid); // Use MQ2 API to look up spell by it's spell id
if(!spell) return false; // Failed to find the spell, so we can't cast it
if(spell->Range >= distance_to_mob) // If the spell's range is greater than your distance to the mob, you can cast on it...
return true; // Spell is ready to cast
else
return false; // Spell is not ready to cast. You are too far away.[/CODE]