Get updates by email: Subscribe
Alright, it’s been awhile, but I promise I havent just been slacking off! When I left off last time, my goal was to create a ‘vertical-slice’ demo level and that’s still the case. However, before I could start making that, I first had to do all the things I had been putting off for months.
Until now I’ve been using an ugly test list to represent objects you’ve hacked. This needed to go, so I to replace it with a map. It had to contain all the objects, so that instead of just reading a list of names, you’d actually be able to see what kind of object, you were hacking and where it was in relation to everything else.
First step was translating 3D object positions to a 2D map.
Secondly, I knew I was gonna have levels with LOTS of hacked objects on multiple floors, aka a lot of little squares. I decided to organize the objects by floor, which meant having multiple maps for 1 level and also the ability to filter those objects by type/color.
Still it was hard to tell which square was a camera and which square was a generator, so I made little icons to represent each type of HackObject. After all that was done, I prettified it a little and put it in the game:
Example shows filtering objects and modifying a camera.
The ugly colored grids of yore are no more! Obviously I cant have a demo full of test textures, so I spent some time updating them. They’re not amazing, but the game definitely does look a bit more like a real game.
I also finally got around to animating the guards and even tested out a flat-color artstyle. For now I’m gonna stick to pixelart though.
Obviously the most exciting topic of all time is file systems, so let’s talk about those. At the end of last sorta-month I had a folder with some files in them, but they didn’t do anything.
I still havent worked on the text files, but image files can now be opened in an ImageViewer and they even have little thumbnails to represent their data. I also made the folder compatible with programs, so a program can request a specific type of file and use it.
Here’s an example where I put an image into the CCTV output and look at it in the ImageViewer.
Okay, time for yet another AI overhaul… I know, I know, but the old one was very cluttered and had an awful lot of duct-tape solutions. One the main issues was that I mostly reused old code from a previous project, which wasn’t optimized for interacting with stuff, which is obviously an important part of this game. It also seemed to do a lot of unexpected things and it was almost impossible to debug.
Okay, enough about all that, what does this new AI do then? First of all it’s very clean. I actually planned out what I was gonna do, before I started coding it. I went with a one-way communication method, that meant I could centralize all the behaviour.
You see, the AI consisted of 3 parts; behaviour, sight and all the other stuff like central control and CCTV monitoring, but the behaviour was being directly affected by things like sight. This meant that if a guard was suddenly chasing me and I didn’t know why, I’d have to look through a bunch of scripts and it was hard to tell when what code was being executed. Also what happens when 2 components disagree about what state the guard should currently be in? I don’t know, I was just crossing my fingers that didn’t happen.
This new method seperates the elements, that make up the AI, so for example, the Sight-script doesn’t know anything about the Behaviour, but I need to change the AI state if the Sight-script sees something, so instead of setting it directly it sends out an event when it sees something, which the Behaviour can then pick up and act on. Let me visualize it:
The communication between the behaviour and Central Control goes through a radio and outputs text to a radio channel. If the guards radio is off, this communication doesn’t take place and the guard want be notified on changes in Global AI State and Central Control wont get reports of suspicious activity. Hopefully this’ll make for some interesting gameplay opportunities.
FSM (Finite State Machine) is used to set the state of the, in this case, AI and indicated what the AI is currently doing. The last AI iteration only had 3; Idle, Suspicious and Alert. This time I decided to step it up. Not to make it more advanced, but to avoid too much behaviour in each state. Let’s break it down:
Blue: Idle stage
Yellow: Suspicious stage
Red: Alert stage
Idle: Patrol by route. Low perception (sight/hearing)
Aware: Same as idle, but high perception
Monitoring: Sits and looks at screens in CCTV room
Intrigued: Check area of something suspicious (heard something, etc)
Alert: Chasing the player until within certain range
Aggressive: Now within range, shoot at player
Interact: Interacting with object
Any state can go to interact and back, this is because when the guard is walking somewhere it might encounter a door, which will need to be interacted with. Once the interacting is done, it’ll automatically switch back to the last state.
The monitoring state isn’t on the diagram, because it’s a bit unique. Not all levels will have a CCTV room, but those that do, will require a guard to be monitoring it, for it to function aka if the player distract the guard and noone is monitoring, then the player can just walk in front of cameras with no consequences.
I’m very satisfied with the quality of my work this month, but not the speed. It took me ages to get the AI working right and I’ve spent way too much time messing around with unimportant things. That said however, the game is looking better than ever and I’m actually already working on the demo level.
This time next month, I’m going to GDC/TrainJam, so if you’re there and wanna meet/talk please feel free to message me, it’d be awesome! I’m planning on having the demo level done by then, so I can have people test it out and show it off. Honestly it’s almost already done, so I’m not too worried about it.
Anyway, once again I’m gonna be gone for a bit, but hopefully there’ll be an update either right before or right after GDC. Thanks for reading!
-Hjalte Tagmose (@hjaltetagmose)
Indie Game Developer, Real Fast