If totaldmg greater than enemycurrentHP, set totaldmg to enemycurrentHP. Is one way if it is total damage combined.
If the problem is when the final bit of damage goes over, then you can say if currentdmg greater than enemycurrentHP, then set currentdmg to enemycurrentHP.