Page 1 of 1

keeping hp and mp values across job changes

Posted: Fri Oct 31, 2014 8:46 pm
by horizon
I've been playing around with on the fly job changes via @changejob, and I'm curious if anyone can help with a question I have regarding hp/mp values.
When a job is changed via changejob, hp and mp are restored to full. Aside from using @hp or @mp to simply reset them to a fixed value, is there a way to note what current hp and mp values are before change > do the job change > reapply hp and mp values on new job?

I would imagine a lua script would be the best way to go about doing this but I have little experience with Lua. Anyone have any pointers or easier methods to accomplish this?

Re: keeping hp and mp values across job changes

Posted: Fri Oct 31, 2014 8:59 pm
by kjLotus
you could just save the hp/mp in the @changejob script and reapply it after

Re: keeping hp and mp values across job changes

Posted: Fri Oct 31, 2014 10:33 pm
by horizon
That's exactly what I was needing. I was trying to think of all kinds of different ways to do it, when the simple method was right there.

Added to changejob.lua just after the valid job id check:
oldhp = player:getHP();
oldmp = player:getMP();

and then at the end of the script after the "invalid level given" else fork:

player:setHP(oldhp);
player:setMP(oldmp);

Thanks!