Wednesday, July 6, 2016

Hammer devlog 34


There are a few things going on here.

The first thing you'll notice is that the left room has changed up a bit. I've done yet more tuning with that test encounter to try and improve the feel of combat. The enemies themselves are also a bit better - the AI has changed a little bit, and that combined with the new room layout feels more "tough, but fair" compared to the older versions.

The next thing you'll notice: new bullet graphics. I've completely revamped the way bullet graphics work. It's not the prettiest thing in the world.

(Mecanim state machines don't allow for instant state transitions, so I actually use a set of lookup tables to determine a state ID to poke into the animator whenever I fire a bullet, because that's the only way to keep it from taking two frames to load into the state with the appropriate clip attached to it. There is a no-shit region declaration, because the arrays that are already in place are like 90 lines, and by the time all of the shot types I'll want are implemented you'll probably have around 1000 lines of "shot_SomeFuckingThing = { animator.StringToHash("shot_SomeFuckingThing_down"), animator.stringToHash("shotSomeFuckingThing_up")..." going on there. Every shot type needs its own value in one of the primary lookup tables, and if its graphics aren't angle-agnostic, it needs its own secondary lookup table to determine which state corresponds to which direction. It's horrifying. The good news is that this actually makes the code itself surprisingly elegant - do some quick math with the weapontype to determine which lookup table we need to use, then turn that value into an index to use within that table and (if necessary) cast the calculated direction back to int and pass it to the secondary lookup table as an index. But, man, those tables are obnoxious.)

Anyway: I can change bullet graphics with angles now. I can also do animated bullets!

The last thing you'll notice: what happens when I touch the ladder at the end of the gif. Replacement rooms are implemented. Literally just another room object that's attached to a ReplacementRoom controller, placed out of level bounds, and told not to install itself into the big World.Rooms array on level load - the ReplacementRoom just watches a flag, and when that's true - and the target room hasn't already been replaced by a higher-priority replacement - it destroys the old room, moves the new one into its position, installs that in World.Rooms, and iterates over all the in-level warps and doors pointing to the old room in order to make them point to the new one. This is kinda costly for simple room-state things - you'd never implement something like that ladder as a ReplacementRoom - but it allows for dramatic changes in level configuration in response to things that occur within the game, which is great. Think of Link's Awakening's Eagle's Tower - you activate a switch, and the entire center of the dungeon map changes seamlessly. ReplacementRoom enables things like that. It's not animated, and I wouldn't actually want to do anything as dramatic as what happens here while the player is in the room, but it provides the ability to substitute a completely different set of tilemaps, collision, and room objects on a whim.

Final note: the ladder isn't actually broken. It looks like it is, but it's not. What happens here, basically: when you touch a rope ladder, it sets the flag immediately in order to ensure that the shortcut remains accessible even if the player leaves the screen or dies while the ladder is still unrolling. It's just a quality-of-life feature - you can't lose a shortcut you've activated just because you didn't wait for the animation to finish; if you don't want to use it right now, you don't need to stick around and wait, you can just start it unrolling and walk off. But the rope ladder in the replacement room is actually a different GameObject, given the way that system works! So rope ladder 2 wakes up, immediately discovers that its flag is already set, and activates itself without the animation. It's just a weird quirk of gluing two shitty test objects to the same flag - the rope ladder works, the replacement room works, but the replacement room using the flag makes the rope ladder look like it's broken.

No comments:

Post a Comment