Resource management

Hey folks.

Been here a few months now. I’ve noticed more experienced builders advising others regarding… well, how much stuff is in their modules.

Which tells me I should probably seek some general advice regarding this before I make decisions regarding how my module is going to work.

Is it better not to have a large palette of custom equipment and instead have loot scripts drop plain stuff and place enhancements on it on the spot?

Is it better to have a single resref for each npc model and just set monster attributes with their spawn script?

I’m sure you can think of similar questions.

How much do these things matter? I’m building a module that is supposed to run as a PW with optional PvP at the endgame, so optimal performance is very much desired.

There are people here with more experience than I, but I can offer some advice:
There are finite resources in the game - I understand (but may be wrong) it has been traditionally around 16,000 separate things (scripts, blueprints, conversations, areas…). I don’t know if this limit is different with EE. So, if you want things to be expandable and not hit this limit, I try to minimize the amount of blueprints I make.

To do this, you have a number of options. I do not believe that this limit applies to items and other things placed into the module in the toolset. If you put down an Area in your module and put into it a number of items and edit each one to be completely different, none of these count to the module limit in separate things.

So, one solution a number of people use involve having these objects in a DM area and when a treasure chest is opened or a critter killed, the treasure is copied from the already placed object in game.

You can do this with monsters/npcs and items. Placeables can be edited once placed, but are not copy-able in the ways NPCs and items are.

Hope that helps a little

1 Like

That is very helpful, thank you. Do the standard palettes count against this limit?

The 16K limit applies to the number of “resources” (GFF files) in the module. You can see what counts as a file by opening the modules\temp0 folder while you have the module open in the toolset.

1 per custom resref
2 per script (3 if debugging)
1 per conversation
3 per area

There are a few files that every module has to have (12 including the palettes).

Standard Bioware resources don’t count.

The good news is that the 16K limit can be increased using haks. While the module can only have 16k files of its own, it can also have up to 50 haks, each hak containing up to 16k resources.

These limits are almost never a problem in Single Player but seem to hit PWs a lot.


performance-wise, blueprints does not slow game at all, it doesn’t matter if you have 2000 items in palette or just 200. All you need is to keep track of the 16k limit and even then there are ways how to workaround it.

What does affect performance is:

  • complicated code in OnHeartbeat scripts, specifically HB script of object that never gets destroyed such as areas, triggers, plot placeables/doors might lag out your module a lot
  • not cleaning areas from spawned content - i recommend to despawn npcs left by players if not immediately then with some delay, it is also good idea to clean lootbags if you spawn them a lot, while the actual lootbag doesn’t reduce performance directly, if you have 30+ placeables at ground and someone casts an AOE spell it can increase the lags a lot
  • spawning too many monsters at once, or designing spawns in way that player can spawn full area, pull all monsters at one place and start killing the npcs with aoe spells. Even worse with AOE spells, I witnessed a 45minutes long server-hangout (linux server top notch machine in 2014) after player cast 3x storm of vengeance into pack of 120 little spiders. This happens with vanilla AI but most likely other custom AIs will have same problem (not verified). The only solution to this is to use Low Impact AI for monsters that you want to spawn in big packs and not even that is perfect solution, the lagginess is still there probably just from the fact that each nwn server is sending packets for each npc to each player every few miliseconds. So if you can avoid spawning big numbers.
  • stacking AOE spells, I didn’t disable this myself but stacking multiple AOEs causes lagginess so it is something to consider, for example casting 15x storm of vengeance prolongs the heartbeats from 6 seconds to 7-9 (this was tested using delaycommand heartbeat workaround under CPP, regular HB doesn’t run at all on big PW modules) similarly when stacked, AOE spells will last much longer than they should (not fixed in CPP, potentionally fixed in NWN:EE - untested)
  • lots of delay commands - delay commands are just as dangerous as hearbeats, make sure to use them with care, when you place a 1sec recursive endless function on each player you will see lags worse then when you would use hearbeat
  • creation/deletion of multiple objects - this is something that is impossible to fix and every MMO-like crafting system suffers. Many crafting systems like CNR (especially), ATS and UOcraft system (least offender) are creating dozens of new objects for every crafting action. You swing tree and it will spawn 3 new items, you kill monster and it will spawn 2-4placeables, after usage further items, tons and tons of items which are then processed into another items, CNR for example can generate about 15 different items (counting those that needs to be bought by player) before you get the final result. Repeat thousand times and each of those object creations will take longer and longer. These craft systems simply bloats modules and you will need daily resets to keep the module fresh. There is no other way.
  • and lastly, allowing players to carry 500+ items, from 500 items higher, entering module can cause huge lags especially if you have a lot of code in OnAcquire event, this is kind of related to the ATS/CNR crafts again as many players will carry lots of 1x1 items be it gems, herbs, mushrooms, or whatever.

That’s a real wealth of info, thanks a lot!

I’m going with a prefix/suffix based item system with 5 tiers; my custom equipment alone would probably be several thousand blueprints. I think a proper loot script is in order. :slight_smile:

How big of an issue is the spawning many monsters at once? I’m planning to have entire areas (23x23) spawn ALL their spawns when a player enters them and have them deleted (incl. items) when the last player exits. Do I need to make triggers instead? The spawns are distributed among the area, not in the same place and it will be too narrow (and the routes too indirect) to run around with huge trains of mobs and actually survive. All these areas will be empty of monsters unless entered by a player.

As for crafting, after reading Mannast’s post I decided to just use the gems from the standard palette for crafting. I’ll use the 5 most expensive ones to determine tier and the rest for determining properties. Thus Craft Armor and Craft Weapon can be used to craft the same stuff that drops from monsters without the need for any additional blueprints. It will just replace 1-4 items in the players inventory with whatever item they crafted. I’m assuming it’s possible to mess with what happens when a player clicks the crafting icon. Otherwise I’ll have to make some special tool items to enter a conversation based crafting menu via unique power. I want to make players select what items to combine rather than have them select what properties and tier to get, to force them to experiment with different combinations of gems.

Spawning npcs itself is not the problem, problem is when player or worse multiple players sees and interacts with 50+ monsters in same spot. If you design your area and spawns in the area that the player can spawn everything and then pull the npc mass on same spot you will experience huge lags. Again if such design is neccesity you can limit the laggines with Low AI impact Set (search at vault it is from me), but thats only partial fix. Also, the laggs are gone after monsters are dead. And until someone pulls whole area and tries to kill hordes of npcs with aoe spells you might never run into this issue.

So either design area so that pulling is not possible (automatically closing+locking doors, door transitions with no return, (random) traps, etc.) or use the Low AI impact set which will however make the npcs really dumb. I think it is not exactly good idea to make 23x23 areas not just from this reason…

But surely the pulling strategy can be limited by other means, afaik this is not possible in MMOs suc as WoW so how do they do it?

I don’t think I will have a lot of issues regarding that, then. All my areas in question are underground areas that mostly consist of corridors. It’s definitely something to keep in mind, though. I was considering more open areas.

As for MMOs: They don’t. Pulling a ton of mobs and AoEing them to death is a common leveling strategy in MMOs. I’ve personally done it in Ultima Online, Shadowbane, Dark Age of Camelot, World of Warcraft and City of Heroes/Villains. And that’s just off the top of my head.

I’m guessing they handle it by having their servers be really, really powerful.