nope, it only sets it to zero if you don't put a value for it in the call
if you do addstat(a,b,2,1), then it sets dam to 0
but if you do addstat(a,b,2,1,"100"), then it sets dam to 100
if I only did it like
def addstat(a,b,2,1,dam)
#things here
end
then doing addstat(a,b,2,1) in the formula bar will throw you an argument count error saying you only sent 4 parameters instead of 5...
so if the new code still returns no damage, then it might mean that the argument you sent isn't evaluated...
you can also try using
addstat(a,b,2,1,"user.atk*4-target.def*2")
instead of
addstat(a,b,2,1,"a.atk*4-b.def*2")