How to prevent screen lock when MacBook AC adapter is unplugged?
Just in case you weren't aware of these options, or haven't already tried this, you could change the Battery settings under Energy Saver. 

Your question doesn't specify what version of macOS you're using, but here are some generic steps:


Go to System Preferences > Energy Saver
Select the Battery tab
Set Computer Sleep to Never
Set Display Sleep to Never
Set Graphics to Higher Performance
Make sure Slightly dim the display when using this power source is unchecked
Make sure Automatically reduce brightness before display goes to sleep is unchecked
Exit System Preferences


Let us know how you go.