Magic system: Replaced a few player/NPC ID checks with slightly faster, more readable and less error prone flag checks.