Mobile::NPC* add_npc( const char* npctype, unsigned short x, unsigned short y, short z ) { Clib::ConfigFile cfile; Clib::ConfigElem elem; if ( !Core::FindNpcTemplate( npctype, cfile, elem ) ) { throw std::runtime_error(std::string("NPC template '") + npctype + "' not found"); } auto npc = new Mobile::NPC( elem.remove_ushort( "OBJTYPE" ), elem ); elem.clear_prop( "Serial" ); elem.clear_prop( "X" ); elem.clear_prop( "Y" ); elem.clear_prop( "Z" ); elem.add_prop( "Serial", GetNextSerialNumber() ); elem.add_prop( "X", x ); elem.add_prop( "Y", y ); elem.add_prop( "Z", z ); npc->readPropertiesForNewNPC( elem ); objStorageManager.objecthash.Insert( npc ); SetCharacterWorldPosition( npc, WorldChangeReason::NpcCreate ); return npc; }