So, I've updated War of Heroes a bit. Lots of bug fixes and balancing changes.
I've also added some forums which you can find here http://www.byond.com/members/TheMagicMan/forum which I will use to post more detailed info on updates.
I have also decided on the next project I will be working on. It is another PVP game, because they are the only worth while games to make/play. It will be a side view game, probably using Forum Accounts library.
The main feature of the game though will be creation and destruction.
You will pick a team and class, then depending on the game type have an objective, whether that is simply killing each other, or capturing the enemies flag.
Each class will be defined in two ways.
The first is what their role is, offensive or defensive. Pretty common sense, offensive are better at killing, defensive are better at defending and supporting.
The second way is whether they are a creator, or destroyer. Creators are good at creating things, they can build walls and so on. Destroyers are the opposite of this, they are good at destroying the scenery, usually with big, flashing explosions.
An example of a creator would be something like a Builder. He can build a strong wall/roof, and an automated turret to attack enemies.
An example of a destroyer would be a sapper. He can plant TNT to deal major damage, or fire a mortar to bombard enemies from above.
I'm not planning on this game taking long to make. I estimate no longer than a week or two before it is playable.
Not every mob takes up the same CPU usage. the default /mob has a lot of stuff going on. The rules for how they move and how they bump into things can be complex. A simple projectile that moves in a straight line won't take up as much CPU.
I think there's a demo called "game-demo" which has turrets that shoot bullets. Running that will give you a better idea of what CPU usage would be like with regular mobs, bullets, moving platforms, and other stuff. |
Yeah, I've tried to optimize as much things as I can. A bullet for example doesn't need to check whether it can walk up/down a ramp, so I simply removed that section from the proc for the mob/bullet type.
One thing I noticed was the proc set_flags looped through all atoms in a view of 2. When you have particle effects that can be a lot, and cause CPU usage to rocket. I've optimized it somewhat. With 50 mobs the CPU usage is now around 70%, which is a decent improvement. The game should be playable with 10-15 players provided the host has a decent computer. |
Not all mobs need to call set_flags (though you can probably get away with dropping the oview(2,src) to oview(1,src)). It sets the on_ground, on_left, on_right, and on_ceiling vars which are only needed for player-type mobs. Projectiles don't need those vars, so you don't need to call it. If you override the movement() proc (like in game-demo/enemies.dm) set_flags (and a few other things) won't be called. If you're just using objects for visual effects and you don't need to worry about collisions you can use objs.
You can also play with world.tick_lag. The demos that come with the library run at 40 frames per second, but it still looks decent at 30 fps. That right there should drop the CPU from ~70% to ~50%. Let me know if you find some useful optimizations, it's an area I haven't really been concerned with. Edit: After doing some quick profiling, no proc seems to stand out as being a CPU hog. set_flags was the worst at 0.000128 seconds per call. Changing oview(2,src) to oview(1,src) dropped it to 0.0000669 seconds per call, but the overall CPU usage was still the same. There are just a lot of procs being called (50 mobs * 40 fps = 2000 calls per second for each proc). Your best bet for reducing CPU usage is to reduce the number of active mobs. In A Miner Adventure, if an enemy isn't on the players screen for a little while they'll deactivate and their movement loop will stop running. |
The problem is highlighted in this screenshot.
http://files.byondhome.com/TheMagicMan/sidescrollermobs.jpg
There is no editing here at all. I simply took the sidescroller library, added a few mobs to the map, and made it possible to see how many mobs existed and CPU usage. 12% with 10 mobs (and I have a quad core 3.2ghz processor).
For single player that is fine, for multiplayer it is not.
Here is it running with 50 mobs.
http://files.byondhome.com/TheMagicMan/sidescrollermobs2.jpg
That's right, 84% cpu usage.
Now obviously, the game would not be suited for 50 players, I'd estimate 10 max.
However, the problem is that the library forces you to use mobs for almost everything. It has no procs for handling the movement of objects like it does for mobs.
Every projectile created has to be a mob, and the game heavily relies on projectiles. Most players will have anywhere from a max of 3-5 projectiles flying at a time. Which is why in the above screenshot I purposely placed 50 mobs, the max I expect this game to have.
However, the game would also have other things running, so it'd reach above 84% cpu usage.
I will continue to make the game, BUUUUUUT, it may simply turn out to be unplayable.
At worst, the game wont be possible to make or play, at best I'm going to have to spend a while messing around with the sidescroller library, cutting out and removing unused parts of it in an attempt to optimize things.