Fixed npc editor. Added some scripting logic for npcs. Cleaned up code.