old thread? doesn't matter... i saw this in the call for goodies section, so it might be still interesting. why don't you make some kind of function instead of the numberous if-clauses?

energy = min(100, max(0, energy*(1+0.1*(use_energy==0)) ));

should do the job faster.