This last week focused on making enemies (in the game).
Enemies
We had an enemy back when the simulator was 3d, so much of this reinvention but with the advantage of hindsight.
For graphics, I was able to easily reuse the turret that the player uses as its model, and with the building component system we can make an enemy building in any shape we want which will be handy later.
This turret comes with a muzzle vector too so we don’t need to reinvent the wheel entirely.
the next step was getting it to fire something. our old example shell is long gone now, so i had to make a better way of serialising munitions. Given that munitions are just a few vars and a state, that involved making the state serialisable.
this had some advantages which ill cover later, but in the meantime it meant we could assemble a munition in the factory and have it saved.
next up; targeting. to make the enemy hit accurately would be very easy if we want it to cheat: make it jsut raycast and we fake some parabolic trajectory. how droll would that be. instead, we want to reuse the same parts that make player munitions possible, so we need real targeting.
Enemy targeting example
The targeting system works like so
- the enemy starts aiming directly at the player
- it then fires and shot and compares the final point of that shot vs the y axis of the player
- it then raises its barrel and fires again
- this loops, doubling the barrel distance until it goes past the player, where it reverses and halves
this has ended up being quite a good and simple targeting system. not totally accurate which gives the player a chance to get a baring on the enemy first
Player Damage
so you’ve been shot in the face, now what?
we want to satisfy a few requirements when it comes to how the player is threatened.
- the player should be under time pressure
- this emphasises good factory design
- the player should take an active part in defending or repairing their design
- helps the player feel more connected to what they’ve built and lets them have a closer hand in the repercussions of their design
- the player should be able to factor defence into their factory design
- lets make meaningful decisions about their creation, sacrifice damage or defence or vice versa
- it shouldn’t feel like shit to get hit
- while the factory getting hurt is part of the game, it shouldn’t be so severe that it feels bad
when a player is hit, the enemy projectile will do some damage to their factory. this damage is randomly placed on some machines and items on the factory floor. damaged machines can be repaired by the player. machines are pretty sturdy so this doesnt need a lot of player attention and a notification will say when damage has reached some critical level on a machine
additionally, fires can be started which pressure the player to come back. fires start small but can grow a lot. if not extinguished early they can easily eat an entire factory. different machines are more likely to start fires when damaged, so this must be considered. fires are probably the most dangerous hazard that can be encountered.
the code for the fires turned out to be very simple but the effect is great, its really something you want to get on top of ASA or it very quickly runs out of control.
**Fire in effect
**
how does the player mitigate this?
in addition to repairing and putting out fires, the player can place reenforced pillars. these soak up the damage for an area around them and have a lot of heath themselves. they are of course going to eat into the available space the player has to build.
Factory improvements
made a few upgrades to the factory while adding fire and damage, and with the addition of export/import features for states, we can now easily have preset levels that are loaded on demand.
furthermore than lets us bring in the main gameplay loop where the player starts with inputs and outputs, build their machines, hits play and sees how it runs, with things resetting (and ammo being removed) when they stop running. i also sped up the factory speed to be closer to how i’d like it to be in combat
faster factory speed
this also let me add some glass that covers the factory while it is running to indicate that the factory is ‘sealed’ and cannot be updated.