When plugged in, battery while charging would add some amount of heat to your system, that adds up with the heat coming out laptop components while gaming, could you monitor several temperatures of your system while gaming and laptop charging and spot the difference ?
Another parameter to take in consideration is that when your laptop is plugged in your it might switch automatically to " HIGH PERFORMANCE" power scheme (through some third party app), or within same power scheme would switch to plugged-in settings allowing higher clocks for the CPU which is good for gaming performance but adds a lot more heat to the system : check your laptop power scheme while unplugged and after you plug it in, in both cases go to advanced view of the power scheme and check different parameters for CPU, PCIe, CPU cooling ( make sure is active at least when plugged in), you could decrease the maximum performance of your CPU and/or lower it's lower limit so it could have lower clocks when not needed >> this is as a last resort)
Also check your laptop fan (or fans) is working (sound or visual check)
While charging and/or gaming you could help ventilating your laptop by keeping it above table level or better getting laptop cooling pad (metal ventilated ones are best), this will help cooling your laptop and increasing it's battery life span as well.