As Thomas said, the ASPELL macro handles this.
Code:
ASPELL(spell_astral_walk)
{
  int target;
  if (!IS_NPC(victim) && ((GET_LEVEL(victim) >= LVL_IMMORT)))
  {
    send_to_char(ch, "The immortal power of %s repels your magic!\r\n", GET_NAME(victim));
    return;
  }
  // Rooms we cannot astral walk from
  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PRIVATE))
  {
    send_to_char(ch, "Something prevents you from leaving the room.\r\n");
    return;
  }
  // Rooms we cannot astral walk to
  if (ROOM_FLAGGED(IN_ROOM(victim), ROOM_PRIVATE) || ROOM_FLAGGED(IN_ROOM(victim), ROOM_TUNNEL) ||
      ROOM_FLAGGED(IN_ROOM(victim), ROOM_GODROOM) || ROOM_FLAGGED(IN_ROOM(victim), ROOM_NOTRACK) ||
      ROOM_FLAGGED(IN_ROOM(victim), ROOM_NOTELEPORT) || ROOM_FLAGGED(IN_ROOM(victim), ROOM_PURGATORY))
  {
    send_to_char(ch, "Something prevents you from reaching that player!\r\n");
    return;
  }
  // Zones we cannot astral walk to
  if (ZONE_FLAGGED(GET_ROOM_ZONE(IN_ROOM(victim)), ZONE_NOASTRAL) || ZONE_FLAGGED(GET_ROOM_ZONE(IN_ROOM(victim)), ZONE_CLOSED))
  {
    send_to_char(ch, "You cannot reach that zone!\r\n");
    return;
  }
  if ((GET_LEVEL(ch) + 5) < GET_LEVEL(victim))
  {
    send_to_char(ch, "You failed.\r\n");
    return;
  }
  if (victim_savingthrow(victim, ch, SAVING_SPELL, SPELL_ASTRAL_WALK, 0))
  {
    send_to_char(ch, "You fail to %s to %s.\r\n", spell_info[SPELL_ASTRAL_WALK].name, GET_SHORT(victim));
    return;
  }
  act("$n opens a doorway in space and steps in.", true, ch, 0, 0, TO_ROOM);
  target = victim->in_room;
  char_from_room(ch);
  char_to_room(ch, target);
  act("Suddenly, a doorway appears from nowhere. $n steps out and the doorway disappears.", true, ch, 0, 0, TO_ROOM);
  act("You open a doorway to the astral plane and step out in front of $N.", false, ch, 0, victim, TO_CHAR);
  do_look(ch, "", 0, 0);
}