Helping deciding the best overall method for a custom map system

Hi all,

First post here, please let me know if I’ve done something wrong.

Brother and I and trying to design and make a series of maps that work off of a Full Invasion system, similar to one that a mod for Mount and Blade Warband uses. For those now in the know, I’ll explain the system:

Players log into the map and choose a troop. There are several tiers of troops one can choose but obviously the higher-tier ones cost a lot more gold, which you earn via hitting and killing enemies. After a troop is chosen, their equipment is chosen and you spawn after the next wave is finished.

Enemies spawn in waves or increasing difficulty. The difficulty is determined by how advanced the game is, the number of players, and probably some algorithm. Waves are broken into sets of three waves followed by a boss wave, where a powerful enemy and his minions are spawned. Finishing a boss wave is followed by another two or three normal waves of increased difficulty, and so on. The game ends after wave 20 or 30, when a super powerful wave is summoned.

Now, there is more to it than that, but in essence, you get the idea. I would love to design something like it for NWN. Making the map is no problem, and I’m no stranger to scripting, but finding the right method is causing some difficulty. You can’t ‘spawn in’ as a pre-determined character with a set amount of levels, and choose and change it on the fly as you like. So I thought of each PC being an invisible sprite that can ‘buy’ a troop from a merchant and polymorph into that troop. Or, they buy a troop who becomes their familiar who you can then take control of. But neither of these systems seem to work.

One can of course base the system from a grounds-up basis, where are you always start off level one and organically level up as the game progresses. But the fun of the Full Invasion mod is being able to join the game half way through, accumulate some gold with kills quickly, and buy a medium-tier troop so that you’re competing with the other players. Also, being able to change your mind half way through, and go from being a top-tier swordsman to a top-tier wizard, and so on.

Another system I’ve been struggling with it how to spawn the enemies. The obvious choice is using encounters, but I can’t get them to work. In the mod, when a wave is finished, a timer starts until the next wave, and then hordes of enemies spawn in one of three locations and attack players indiscriminately. I haven’t been able to get the encounters to work, either because you have to re-enter them, or they don’t spawn enough enemies, or because I can’t figure out how to enable them only later on in the game.

To get to the point, how would any of you approach the overall systems of the game? Where should I be putting my attention? I would love for this to work, and actually be playable by 3-20 players at once. I know that might tax the game a bit, so I’m hoping the scripting and everything will be as light as possible. If anyone has heard of a mod that does something similar, that would provide some inspiration, please let me know.

Thank for reading!

How should a troop behave? Roughly how big is it?

As you probably know, in NWN each player controls just one PC, not a troop as such.

You can level up the PC to a target level on entry. You can polymorph the PC into the troop leader. You can change many PC abilities on the fly via equipment or skin bonuses.

If the troop is small, the troopers could be henchmen. They will follow the PC but break ranks to melee when they see the enemy. The PC radial menu can order the troop to stand still, follow, guard the PC or attack.

For performance reasons, larger troops are best implemented as NPCs with a minimal script set. You can make them move in formation, as shown about 37 seconds through this short video:

However, by default, they will break ranks to melee, with no built-in means to issue orders. Some of that can be rescripted easily, but the core AI is a mare.

As for enemies, personally I wouldn’t bother with Encounters as it’s easy to script exactly what you want.

The devil is in the detail, so you may get more help by asking very specific questions, with examples of what’s not woring for you.

1 Like

Hi Proleric, thanks for the reply.

I should have stated, sorry about that, that when I say ‘troop’ i mean an individual soldier. You choose just one figure to play as, as Mount and Blade is a single player game (although in SP, you can issue commands to armies using shouts, but not in this particular mod).

That is why I think it should be possible to do in NWN, although how exactly is to be decided. So for now, it’s finding a way to ‘jump’ to a chosen, leveled, equipped and ready-to-fight soldier from a list (or container). Polymorph was my first choice, as I can script that easily, but I don’t know how to design a custom polymorph? Is there a blueprint for it? That would be the easiest option.

Well, the specifics as to what aren’t working, is the wave system. I need a streamlined way to spawn a large number of foes on one to three waypoints (and the creatures need to single-mindedly seek the PCs to destroy them, not wander around). The quantity of enemies needs to be scaled to the average level of all the players who are logged on to the game. The aim is that the PCs collaborate to destroy each wave. Encounters are limited to 8 creates, which isn’t enough. I also don’t know how to get encounters to increasingly get stronger and stronger, and larger and larger, with intermittent boss waves.

If you reckon that a straight up script (on creature death? as in - when creatures dies, add to integer tally, then when tally is high enough spawn more creatures, etc?). On heartbeat? When a PC hits a switch? I don’t know which is safest and most streamlined for online play.

I reckon I can get around most problems with a simple solution. Like - put a container in the level, PCs “Buy” a soldier which they polymorph into onAcquired. Creature onDamage and onDeath can easily handle the gold acquisition for player characters. Just don’t know how to handle the wave system.

Thanks for the clarification. In the UK, “troop” is a collective noun for “trooper”.

To change a PC into a trooper, you need a script that cycles through the trooper’s equipment, creating a copy of each item and equipping it on the PC.

Perhaps the most natural way is to create trooper NPCs in an inaccessible area for use as reference. Logically, though, you could keep the equipment lists in a 2da file or in the script itself.

I’m not sure which abilities, feats, skills etc you need to change on the PC, but again you copy most of that from a reference NPC or list to the PC skin as temporary bonuses. There are some constraints, like you can’t easily change the PC’s class or level, but you can add bonuses.

For enemies, OnDeath is the way to go. You can set a counter when the wave spawns, decrement it on death, then, at zero, spawn the next wave after a delay. Or, if you prefer, use the tag to detect when all enemies are dead.

If you allow magic, you may need to test for other conditions, or decide what happens when an enemy is hors de combat. If they are permanently out of action but not dead, the next wave will never spawn unless your script handles this.

The other thing to know about OnDeath is that dead people’s scripts can’t tell others to do things in the future, such as delays and actions. The workaround for this is to assign those things to the module itself, using ExecuteScript or whatever.

In summary, sounds like much of what you want to do can be done.

Thanks Proleric. A lot of direction there, but just one or two follow up questions…

Let’s say I want to muck around with the Polymorph.2da, and add a few creatures (soldier types) to it, and try that method. Where can I find it? My searches have so far been in vain - is it module specific, if I make changes to it, or game-wide? How easy would it be to add 20-30 soldier types to it?

I’m not sure what the advantage to copying an existing creature’s equipment/stats is as opposed to scripting it from a list, or indeed how to do it, can you explain? Also, I’m guessing the equipment list.2da is in the same place as the polymorph one :stuck_out_tongue

I hadn’t even thought of magic. Now that you mention it, it could really break the system. If some enemies become petrified or something similar, that would definitely cause the tally counter to become stuck. I will make sure to script constraints on that (thank you!)

So you’re saying decrease the creatures_remaining integer stored, for example, on the area, by one point per death of creature, on the same script detect if it is at zero, if it is - then execute separate script which delays the spawning of the next wave (which will also be detected by the area’s current_wave integer), an so on?

Getting a lot more clarity with this, many thanks indeed (and apologies for my endless questions - I played this game a lot as a kid/teen, now that I am an older man it doesn’t come as naturally to me haha)

You might want to refer to the Custom Content Guide section on Creatures. There are bits on model-making which you can skip, but the explanation of 2da files and body parts is well worthwhile.

You’ll need the latest NWNExplorer to extract 2da files - available from the Beamdog Forum under Tools.

Your modified 2da files are added to the game as a .hak file.

Much depends on whether your troopers are part-based models (in which case you change their appearance by equipping armour and weapons) or holistic models (which are appearances).

If you have holistic models, it’s very easy to add any number of them to appearance.2da. Then you can use the method SetCreatureAppearanceType, or update the Polymorph system if you prefer.

The only advantage to using a reference NPC, rather than a list, is that you can see what it looks like in the toolset, which matters when equipping part-based creatures.

Your undersranding of OnDeath is correct.

Upon looking at how complicated it would be to implement a system exactly like Full Invasion in Mount and Blade, I’ve decided a better option would be a natural level up progression. If a new player enters the server on, say, wave 8, they will just be rewarded an amount of experience based on the average player level, to bring them up to speed. A greater sanctuary effect can also be applied for a few minutes to give them time to level up to their liking so that they can then get into the action and not be too left behind.

The script for the enemies spawning is driving me crazy. It wouldn’t be so bad if there was only one type of enemy, but I wanted a good mix of baddies of increasing levels interspersed with the odd boss. I’ll get there though. I think it’s beginning to come together. I’ll be sure to ask if I have any other pressing issues, but that has given me a huge amount of help, many thanks indeed.

Also, will be sure to let everyone know how I get on, as in, if it ever becomes playable! Fingers crossed

1 Like