Author Topic: Need Help with NWNX Functions  (Read 432 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need Help with NWNX Functions
« on: September 23, 2011, 09:33:05 am »


               I'm not able to get the Max Hit Points to Set, for some reason...

#include "nwnx_funcs"

void main()
{
  object oPC = GetPCSpeaker();
  int nMax = GetMaxHitPoints(oPC);
  int nNext = nMax + 10;
  NWNXFuncs_SetMaxHitPoints(oPC, nNext);
}

Does Nothing (yes I'm hosting the module on a NWNX Lan Server)

Anyone know how this isn't working?
               
               

               
            

Legacy_Failed.Bard

  • Hero Member
  • *****
  • Posts: 1409
  • Karma: +0/-0
Need Help with NWNX Functions
« Reply #1 on: September 23, 2011, 10:18:50 am »


               It works (mostly) right with NPCs, who have a bonus HP data field that can be manipulated. Oddly, nMax + 10 was adding 11 HPs to the NPC I tested it with though. I couldn't get it to work at all with a PC.


NWNXFuncs_SetHitPointsByLevel(object oCreature, int iHP, int iLevel) -- that one will work for PCs, but I'm not sure you can use that to raise the HPs beyond what their max was at a given level without issues.
I think the particular check I'm thinking of is only done at level ups though, so with a level 40 character that might not ever become an issue.

Edit: This one might be useful as well, but I've never tried it.
void NWNXFuncs_ModHitPointsByLevel(object oCreature, int iHPMod, int iLevel);
               
               

               


                     Modifié par Failed.Bard, 23 septembre 2011 - 09:29 .
                     
                  


            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need Help with NWNX Functions
« Reply #2 on: September 23, 2011, 10:40:56 am »


               Thank you Failed.Bard, looks, like they will just have to settle for more HP for raised constitution.

Thanks. '<img'>
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
Need Help with NWNX Functions
« Reply #3 on: September 23, 2011, 10:50:04 am »


               It should be noted, that the nwnx SetMaxHitPoints by level function has a limitation of 255 hp per level.

If you try to raise your hit points per specific level, beyond this, it will wrap round, and return to 0 for that level.

I implimented a custom leveling system, that has your bioware level at level 1 always, but when your hp for level 1 approaches 255, then the system levels you to the next bioware level (2), which then provides you with an additional room for 255 more hp.

Its something along the lines of
x = CurrentMaxHP/255

if x >= CurrentBiowareLevel  then we need to level up to the next bioware level.

Attempting to set MaxHP For a bioware level that you have not gained, will cause the server to crash.
Resolve this by
Leveling up to level 40, use Levelup henchman function, to do the leveling automatically.
Then de-level to level 1 again  - This creates the fields and level stats structure, and can resolve the potential crashes.

Now the set hp at level function, shouldnt crash.
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Need Help with NWNX Functions
« Reply #4 on: September 23, 2011, 11:43:33 am »


               I'm not using it for henchmen, was going to use it in my Custom God Level System (bottom of the page)...

Anyway there was no need, as the PC gets 40 HP every time their constitution is raised by +2, so that's cool...