The problem with writing articles like these is that they are always written with perfect hindsight. As you might have guessed the actual progress on this project is some weeks in front the things you read about here and I've had plenty of time to work out the problems, throw out the experiments that don't work and organise a sequence of events that is logical and (hopefully) makes sense.
The reality is always much more chaotic than that and occasionally you get bitten on the ass. Hard. As a token gesture towards a more representative set of articles I'll tell you about my nightmare week this week before we look at the first appearance of the Ghost Warriors in combat.
You might remember me rattling on about Pathnodes a few weeks ago. Pathnodes are special objects that you place in the map before hitting the 'build' button to generate a path network. This network is used by the bots to navigate around the place. At the start of this week I was working on some ideas for the AI scripts, specifically a set of 'orders' that would enable the player to order the Angels around the place. The principle is pretty simple, a conversation menu executes a bit of script to make the bot do something, the text option 'follow me' executes the scriptline 'gotoactor Player' and the bot continues to go towards the player character until told to do something else, like wait on the spot or go back to the bunker.
So I was trying it out and it was working pretty well, I had Lucy stomping all over the place following me around. The problem arose when I ordered her back to the bunker, she stubbornly refused to move. The engine provides some debugging tools to give you a clue when things go wrong and colour codes the characters according to what flavour of badness is happening. Lucy was turning blue:
...which means something like 'unable to build path to target'. The problem was that Lucy could no longer find the pathnetwork from the remote spot in the desert that I'd led her to. Looking at the path network included in the map I'm borrowing it wasn't surprising, the Legend designers never intended there to be any action in the desert so the pathing was very scarce. If I wanted the player to take bots anywhere on the map then I was going to have to make sure that the bots could find their way back onto the path network from anywhere.
Unrealwiki has a boatload of advice on creating path networks and it was there I found out the terrible truth. At the Unreal II level of the Unreal technology bots can only find a pathnode within 300 map units. That's this far: >---<
In order to make sure a bot can find the path network from any point in the level I was going to have to hand place a pathnode every 300 units. This isn't a big map, but it's open terrain. The pathing method was developed from a system that was intended to lead AI characters around corridors and into and out of rooms in more or less straight lines and direct routes, it was never really intended for the purpose I want to put it.
So this week I've been placing pathnodes. About a thousand pathnodes. Hand placed, height adjusted and built, rebuilt, adjusted and tested. Every night this week for two to three hours a night, place a node, check the distance between, build the network, place another node, check the distance, build the network. This is what the network finally looks like in the editor:
These are the hard times, when it's nothing but boring repetitve labour, when all the high thoughts of character development, exciting firefights and creating something that someone might be able to derive some pleasure from have evaporated and it's just place a node, check the distance between, build the network.
That's when the TV starts to look more interesting, when going out to the pub looks more appealing, when anything looks more interesting than placing another sodding pathnode. It's times like those when most mods die, I reckon, when it all goes quiet on the forums and all the big ideas disapppear into smoke.
Anyway, job done, Lucy finds her way back to the bunker from everywhere I've tested so I think I can say that we got away with that one. The worry that remains is that the level now has a frankly inordinate number of pathnodes and a level of path network complexity that might cause us problems further down the line. Don't quite know what kind of problems exactly, only that according to all of the Unreal mapping wisdom the mantra for placing pathnodes is 'less is more'. Hrrmph.
Onto the Ghost Warriors. The first event is a sniper team that move quietly into place and take up a position to take shots at the bunker. The Angels won't have any weapons able to hit the snipers and will have to close range with them across the open or else leave them out there and have one more thing to worry about later when more Ghost Warriors turn up.
Last time we created copies of the classes that define the mercenary characters used in the original game so we could customise them as we like without impacting the code of the original game (shut up, we did, OK?). We can add two of these custom characters to the map, these forward scouts will be the light versions of the soldiers.
These scouts will start with the default settings and equipment from the off. We want them to be quite specialised and we could override these settings in the map editor but then we'd have to keep track of which Light Ghost Warrior was specialised and which were the defaults. A better way of creating special cases is to adjust the script externally, that way any character that is set to use that script will automagically gain the special settings.
The first thing we need to do is drop the assault rifles from their inventories and replace them with the long range sniper rifles. These weapons will represent quite a threat to the player, they do a lot of damage from a great distance. As long as we're careful though, we can create a self-balancing challenge for the player. The risks involved in taking out these snipers will be rewarded by the acquisition of one of the most powerful weapons in the game. I think we'll limit the available ammo, though. We don't want to make camping out at a distance an easy way to wipe out the attackers.
These lines remove the assault rifles and add the sniper rifles:
removeinventory giveinventory U2Pawns.PowerSuitJapLight setweapon u2weapons.weaponinvsniperrifle
Next we need to put on our generals hat and choose a vantage point from which our camping little bastards are going to ply their trade. Let’s take a tactical overview of the bunker and the surrounding area:
I’m imagining the Ghost Warriors to be moving up from the south (I’m only calling it south because that direction is at the bottom of the screen in the map editor), which makes the ramp at the entrance of the bunker south-facing.
There’s a raised plateau to the north of the bunker, a ridge to the south and open terrain east and west. The east is where we landed the dropship when we worked out that sequence.
I can see two possible vantage points that have cover and a clear line of sight to the bunker, the skeleton to the east and some dunes to the west. I’m loathe to divide the two snipers at this point because I want a clear focus for the event when it occurs. It’s much easier to have an NPC point out that there are snipers ‘over there’ than try and get across that there’s snipers ‘there and there’. I’m tentatively thinking that the crux of this encounter will be one of three outcomes, either the player will take off and deal with the snipers herself or she’ll take one or more NPCs with her or alternatively order an NPC to go out alone.
I’ll pick this spot here:
...and we’ll start them off there at the back. One thing I have learned since we last looked at making NPCs go to places is that you should never use a pathnode as a destination object. It’s kind of obvious, now I have a better idea how bots use the path network, but when an NPC squats exactly on a pathnode he effectively blocks that path for everyone else. Because of this I’ve starting using an object called a PatrolPoint, but the principle is the same, it’s used simply as a named point in the map to which the bots can refer. I also found an object called a LookTarget so we’ll use those to make the snipers look towards the bunker.
Here’s the code to send our snipers to their respective destinations:
ontrigger SpookScouts gotolabel Move1 sleep :Move1 dormant 0 setstance standing setmovespeed 1 onevent AutoBegin gotolabel Move1 onevent AutoEnd gotolabel Move1 onevent SeeEnemy gotolabel Snipe gotoactor PatrolPointGreen1 :Snipe setstance prone setmovespeed 0.5 turntoactor LookTarget4 sleep
A quick test. Here they are starting out:
Reaching the destination:
...and I can make them drop into prone positions like proper snipers:
The only problem we have now is that the snipers don’t snipe. You can jump up and down and show your arse at them from the bunker and they don’t so much as bat an eyelid. This is probably because bots don’t really ‘see’ as such, the simulation of their sight is really just a radius with some blocking calculations in between. The bunker lies outside of the radius, so it’s just as matter of increasing this property when we set them up. While we’re at that we’ll make them go dormant until they get an event name (SpookSnipers) and we’re done:
Ouch. Let’s cross them off the plan and then next time we’ll bring some more soldiers in to make a more determined assault on the bunker.