Maximum values for intergers

Hey all.

I’m wondering if there is a maximum value for integers, or if they can be literally any value? is there a cap? If a player has an int+1 set everytime he, say, performs an attack, will it eventually glitch out because the value is several trillion or whatever? I seem to recall some final fantasy games that limit me at 255 anything, othergames have a cap (I’ve been told) somewhere around 60.000. Anyone know what the case is for NWN?

I’m making an “infinite dungeon” but it’s only infinite if the integers are. :stuck_out_tongue:

The ints in NWScript are 32 bit so can be anywhere between -2,147,483,648 to 2,147,483,647.


What happens if a script tries to set/return an int beyond that cap?

It should just wrap around. Adding 1 to 2,147,483,647 will give you -2,147,483,648.

32 bit numbers are fairly large values it is extremely unlikely that you will ever exceed its limits under proper usage in NWScript.

I see. Thank you for the quick replies! :smiley:

the answers are accurate for “integer” data type in general, however character statistics like abilities, skills, hitpoints are not stores as integer, abilities can range from 0- 255 max, skills from -127 to +127, not sure about hitpoints. Also there is question how do you intent to raise these stats, without nwnx you need to use Effect* functions which have cap on its own (12 abilities, 50 skills)


@Shadooow is right. Those lower limits would be your bigger concerns. Even if you raise the cap on ability bonuses to 1,000,000 using SetAbilityBonusLimit() under EE your ability scores are still limited to 255 max. Same thing applies to skills too.

There is also the problem of balance once you get into character level 40+

1 Like

The +1 int for every attack was just a realistic example of something that might actually get that high.

The script in question will be put on an area transition. It will load a random area for the player that enters it and depending on the players direction (moving north, east, south, west, up or down) the area he enters - once selected - will be set to the players current areas coordinates+1 (IE player is moving north, next areas Y integer will be set to this areas Y integer+1.
This is so that if another player uses the same area transition while the first player is still in the area it led to, the second player will be transported to the first players randomly generated area instead of one generated for him.

The max integer is literally the cap on how far you can go. 2.1 billion dungeon areas seem beyond even the most dedicated player.