The Daily Click ::. Projects ::. Squad
 

Project: Squad
Project Started: 22nd September, 2011 Last Update: 17th December, 2011
Project Owner: Muz Project Members:
Project Type: Shooter management Project Progress:

Coding a battle engine
Posted 27th Nov 11, by Muz  
The battle engine will be 2.5D, which means that the characters will be somewhat side view, but be able to walk behind or in front of one another, even when overlapping. More importantly shots like bullets and rockets will go behind each other without overlapping.

It was initially a bit of a challenge to code, but one trick I found was to create sort of a XY base for the characters and objects in the game. Treat the base sort of like how you'd treat top-down code, which makes it simple 2D. Then add an extra Z (up-down) angle to it, and check whether the bullets go too high or too low.

Unlike the typical klik method, bullets won't be shot around and collision detected. It's quite possible to just collision detect, all I have to do is treat the shots like it's top-down, and check if that hits. If it does, check if the z-position is right for a hit to the head or feet or whatever. It's simple enough, but in my experience (and hearing about the experiences of many others), collision detection is buggy in MMF2. I'd rather spend an extra week working on the long route, than a few frustrating weeks debugging the collision detection, then giving up and passing down the frustration to the player.

So, simulation it is. The shots will be simulated by finding the angle and direction of the shot, and then adding a little inaccuracy to that angle. Then we trace where the bullet ends up. If the location of bullet is somwhere where there is already cover, then the bullet hits cover. If the bullet is aimed at someone's head, but the angle slides a bit and hits the arm instead, then it hits the arm. The more difficult problem seems to be checking whether a bullet hits cover, as there's too many bits of cover around.

There's a few approaches I've considered.
- The easiest method is just to scan through every bit of cover on the map and check if it hits anything. The problem here is that it's probably computationally intensive. You've got 6 sin/cos per bullet. With approx 40 parts of cover in a map, that's 240 per bullet... with 20 bullets flying around per second, 4800 sin/cos per second? It'll easily hit 10k+ with more bullets and a large map, with lots of units. It's not too bad with modern computers, still, it's a sloppy solution.
- A more classic approach, used by many games, is to determine sort of a cone of area where the bullet may go astray, and then choose something within this cone. It's not a bad approach at all, but I feel too much effort to code/debug.
- Another classic approach is to only examine the cover around the target, and check if it hits that (probably a higher chance of hitting cover the further away the shooter is). Then sort of draw a line from the shooter to the target, and tick and check everything along the way. I think games like Jagged Alliance use this system, so it's a decent enough one. The main problem here is trying to draw a line with MMF (without collision detection).

> My chosen approach was to set every location on the map as a 'tile'. At the start of the map, the game remembers which 'tiles' cover is in. Then, upon shooting a bullet, the game only checks the objects in tiles passed through. It's a little more work since I'd have to set up a tile-based system. But the advantage there is that I could just apply it to a tile based pathfinding system as well, since the obstacles will be mapped out too.

Posted by lembi2001 27th November, 2011

Wow Muz simply Wow!

This project is sounding really good and I hope it will play as good as it sounds. Is there any chance you would be releasing some of your Engine as Open Source when the project is finished? It'd be really cool to see how you have accomplished some of the actions you have done.
 
Posted by Sketchy 2nd December, 2011

I love squad-level strategy games and I love rouge-likes, so this sounds interesting.

I don't get it though - what exactly does the player actually do? How much control do they have once a mission begins?
 
Posted by Muz 16th December, 2011

I was actually planning to release the engine as open source as soon as I finish it, one of the goals was just to create that kind of engine.


Once a mission begins, they have no control They pretty much just choose who to go into a fight, and what weapons they're equipped with. Though the weapon combos do matter, and if you send 4 assault rifle guys in, they'd be maybe more effective in open maps with little cover, compared to say, 2 assault rifle, 2 sniper kind of teams. Though snipers would be more useful with/against heavy cover. Whereas you need a bazooka guy against any heavily fortified thing.

It's sort of like <a href="http://frost-guard.minitroopers.com/">Mini Troopers</a>. Though you'd have to build a 4 man team in that game to get what I'm trying to convey. It's a very simple game, yet it's the kind which is endlessly entertaining. I sort of got the idea for this game, after finding all the stories and tactics people come up with for Mini Troopers.
 


 



Project Forums


Favourite

Advertisement

Worth A Click