keeping hp and mp values across job changes

Any discussion not related to the other forum topics
Post Reply
horizon
Posts: 29
Joined: Wed Sep 24, 2014 10:28 pm

keeping hp and mp values across job changes

Post by horizon » Fri Oct 31, 2014 8:46 pm

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?

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: keeping hp and mp values across job changes

Post by kjLotus » Fri Oct 31, 2014 8:59 pm

you could just save the hp/mp in the @changejob script and reapply it after

horizon
Posts: 29
Joined: Wed Sep 24, 2014 10:28 pm

Re: keeping hp and mp values across job changes

Post by horizon » Fri Oct 31, 2014 10:33 pm

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!

Post Reply