Month: July 2016

Fiancée Game – 07 – Enter the Companion

Estimated Hours of Work Since Last Update: ~11 plus a 4.5 hour dev stream

   Hey, a weekly update that’s actually on time! Not only that, but I’ve hammered out a decent amount of work this week, too, due to catching a really nasty head cold and otherwise not being up to doing much around the house.

   Last Saturday (the 2nd) I even streamed some development of Fiancée Game and had a really good time. Definitely going to do that again!

   Anyways, enough about all of that, time to dive into all the new things I’ve gotten plugged into the game this week!

The Companion
   The player’s companion has been implemented to the point where it’s combat effective. It derives all of its stats off of the player’s, so as the PC gains more power so does the companion.

   I still have to implement some display information for the companion and I feel that I need to tweak his final stat values a little bit, but overall he feels like he’s about where I want him to be.

   I dislike UI work. I find it incredibly tedious, even though Unity makes it easier than doing it by hand. Still, I actually got a decent amount of it done this week with regards to adding a character sheet to the game.

So I hear you have a thing for numbers…?

   I would say that I spent between four six hours getting the character sheet implemented to its current state. Most time was actually spent getting the information I wanted in the space that I had. As you can see above, there’s still room for just a little bit more information in the ‘Secondary Stats’ section but I don’t have anything to put there yet. I also still have to implement variable display for resistances, but I’m not in a rush to do that since they aren’t taken into account by anything yet. Graphically it’s a work in progress and I haven’t even started on the Companion character sheet, but it should mostly be copy/paste work. I also need to implement the character sheet (and skill sheet) closing the inventory and minimap when the player opens them on a screen with a resolution that has a width less than 1080 because otherwise they obscure the player’s inventory and gear.

   I also spent a few hours completely rewriting how the game handles tooltips. The previous method was sloppy and slow, now all tooltips pull their functions from the global functions script instead of having to do everything in their own script. I also changed how they display a bit; now if they’re an item or a skill they show the icon of whatever you’re mousing over in addition to providing the relevant info.

An item tooltip! Still a bit of a work in progress, but I like ’em better now.

   The combat saw a bit of work this week due to the addition of the Companion. I had to add functionality to all current ‘kill the thing’ scripts so that enemies will properly damage the Companion and so on.

   During the Dev Stream I implemented a victory screen that pops up after combat and gives the player a chance to grab their post-murder rewards. Assuming they survived. Item drops are added to a small ‘loot’ list and can be taken if the player desires. I’m planning on re-writing how the loot slots function in the coming week since they don’t currently support the rewritten tooltip system.

We survived a fight and even managed to snag an item out of it!

   In addition to the spoils of battle, the player can now gain levels. Currently a level grants you some bonus health and energy based on your class, three points to allocate to ability scores, and a skill point that can’t be used for anything quite yet. I’m hoping to have a rudimentary version of the skill system implemented by next week but it’s going to require some work on other systems to tie in functionality for things like passive skills.

Bug Fixes
   As per protocol there were a handful of bugs that I set out to take care of this week. I think that from now on I’m just going to copy/paste my notes on bug fixes instead of going into long paragraphs over them. So, for this week, I fixed the following:
   – Enemies at low health (2/22 HP on a kobold chief) have a full health bar display. Probably an error in handling the display as opposed to math error.
      – Yup. Display error. Didn’t take into account enemies with 1% – 9% health, only 10%+.

   – Null item returns when rolling for loot for a creature that has a loot table but doesn’t throw out any loot. Probably not really an error, just a poorly placed Debug.Log command.
      – I didn’t take into account the player just not rolling well enough to get loot. Whoops.

   – Torch timer counting down when not in ‘exploration’ mode.
      – 30 second fix. Made sure that the timer only counts down in exploration mode.

   – Doors (and secret doors) facing N/S don’t work because reasons.
      – Code was correct, but the script was referring to the door’s button’s worldspace position instead of the door’s. This lead to… problems.

   – Fix borked particle effect on N/S doors.
      – I was incorrectly getting the parent object’s rotation. Looking at the base rotation instead of getting it as a Euler angle.

   – Player Health/Energy bars do not move on the Y axis when re-positioning them in the UI. Has to do with their vertical resizing.
      – Linked their position on the Y axis to their parent object’s Y position. Easy fix.

   – Finally fixed all the null reference exceptions to things that exist. Was due to scripts looking for stats at the time of creation. I pushed the referencing code from Update to LateUpdate so everything has a chance to set itself up for proper referencing.

   – Gold drops at the end of combat are borked. Waaaaaay too high.
      – Was rolling dice based on min/max gold for an enemy instead of generating a number between min/max. Rookie mistake!

In Closing
   This was a really solid week for me with regards to getting things implemented in Fiancée Game. I’m hoping the coming weeks are as fruitful.

   As you might have noticed from the screenshots above, the worldspace looks a bit different. I’ve scrubbed out all of the realistic looking graphics and I’m aiming for a more 8-bit/16-bit feel to how the world looks. I just think it works better this way, plus it gives me an excuse to avoid having to 3d model decor for the world, I can just use 2d sprites instead. Fun!

   In the coming weeks I want to finish up the UI work that I need to do, which will amount to finishing off the Companion’s character sheet as well as the skill sheet. I also want to get tooltips implemented for non-skills/items so that a player could, for example, mouse over their might score and it would break down where its total is coming from.

   The biggest upcoming hurdle is that I also want to get skills for both players and enemies implemented into gameplay. Once that’s done I’m going to have to do some work on getting a proper AI routine put together for the enemies in combat. My experience working with AI is dated (very dated) so it should be a learning experience, to say the least. I’d also like to do more development streams; I had a really good time with the last one, though I’ll probably keep them a bit shorter than four-and-a-half hours.

   Until next time!

Read More Fiancée Game – 07 – Enter the Companion

Fiancée Game – 06 – UI Work and Combat

Estimated Hours of Work Since Last Update: 12 to 16

   Unlike the past few updates, I’ve been putting a fair amount of work into Fiancée Game over the past few weeks. My goal is to get something playable in her hands by the end of July. I’m fairly sure that if I really bust my butt, I could have something playable in her hands by the end of next week.

   I don’t want to say that this post is going to be massive, but there’s a pretty decent amount of stuff to go over since last post, so, y’know, hold onto your butts, or something!

UI System
   I’ve moved all existing UI elements over to the new UI system introduced in Unity 4.6 (we’re currently in version 5.3, I made most of these elements before Unity 4.0 released) and gotten them jiggered so that they properly place themselves dynamically on the user’s screen.

All elements of the UI dynamically place themselves based on resolution.

   Most of the elements were easy enough to transition over, but I had to reprogram the minimap in its entirety. It was something that needed to be done since the previous method I used to draw tiles was hardcoded to the size of the minimap and was something that I’d always intended to replace.

   While the minimap looks and functions identically I can now, with the re-write, make it scale to be as large as I want it to be. This scaling will be useful later on when I implement a larger ‘world map.’

   I implemented health and energy numerical displays to the player portraits. I’m hoping to eventually get status effects on them, too. Think Baldur’s Gate minus the red coloration on the portrait itself.

Music & Sounds
   I’ve added rudimentary support for a music player to the game. I’m planning to expand it to play music based on where the play is in the world. I don’t expect this to be too difficult to implement since I’ll likely just be reading what music to play based on the tile the player is in. I’ve already added music_Exploration, music_Combat, and music_Boss elements to the dungeon system so it shouldn’t be too painful to hook this into the music player. It’s definitely something low on the priorities list, though.

   I eventually also want to hook the ability to play sounds into the message system. This will mostly be used in combat to play sounds when attacks hit or miss, and when abilities are used. I could also use this for adding sound effects to certain cells when the player enters them.

   The combat system has seen the most work over the past few weeks. I’ve implemented a rudimentary combat loop and enemies now fight back (currently only with basic attacks). I’ve also finally gotten around to implementing enemy name displays and even threw together a (poorly drawn) health display system for the enemies you’re facing in battle. I still want to add some visual feedback (blood splatters, enemies shaking around when hit, floating damage numbers, et cetera) to combat to give some feeling to attacks and whatnot.

Fite me IRL, ye scrubs!

   I currently need to implement a victory/defeat screen so there is a chance for the player to obtain precious loot from defeated enemies, or taste defeat after a total party kill. I also need to stop putting off the implementation of the player’s companion.

Bug Fixes & Functionalizing

   The third enemy present in combat had been causing issues for a while where the game would not properly display its name and its attacks really didn’t do anything. I’d put off working on this until I got to fleshing out the combat system itself. The fix was simple enough, I was just passing a target variable incorrectly. Easy fix, but in doing so I noticed a few other bugs that had crept into the code via lazy copy/past proofing. That’s Late Night Coding™ for you.

   Player health bar displays were bugged (read: not actually displaying health) due to
changing how player health is displayed in-game. I went back and fixed
them. Also fixed a display error that cropped up when health was reduced
to less than 0 and then increased to a value higher than zero again. I still have to implement the companion health bars.

   The biggest bug I fixed was actually with how the combat system read monster stats. Early on I’d run into a bug where sometimes enemies would die even when you missed them without having damaged them in the past. I had no idea what caused this bug, but it revealed itself in earnest once I’d implemented health bars for enemies. Looking into it, it had to do with how C# (and most programming languages) handle copying data. For example, if we were to use the following code to instantiate a new object (assuming that class_Enemy is a class containing an enemy’s stats):
  class_Enemy enemy0 = new class_Enemy();

   We would expect it to create a copy of the data present in class_Enemy within the new enemy0 object. It doesn’t, instead it creates a reference. Why is this? The reason is because by default C# makes a shallow copy of data when you copy it in the above way. What does this mean? Basically this:

Thusly have we learned the value of a deep copy over a shallow copy.
And yes, I’m aware of the typo.

   What this means is that if you change a value in the reference for one object that uses that reference, it changes it for all objects that use that reference. So, if, for example, I had an enemy with 5 HP and dealt 6 damage to it, ALL enemies with the same reference would take that 6 damage.

   While this isn’t a problem in some cases like the player where there’s only one of them, it cause issues where we might need multiple copies of an object that have slightly differing stats. This would be an issue with the item system, too, if I weren’t using static items. It’s certainly something I’ll have to keep in mind in future games, though.

    Finally, I spent several hours segregated a lot of code into its own functions. This makes it easier to call for various things I might need to use it for. Dealing damage, for example, was previously hardcoded into attacks, now I’ve separated it into its own function that can be called wherever I need to do so. This is super handy and cuts down on useless code bloat. There’s still more to be done, though. Lots of old Late Night Code™ remains and needs to be replaced or optimized.

In Closing
   I’ve gotten a lot done in the past two weeks. Substantially more than I’d intended to, in fact. That said, my list of ‘things wot need done’ is still growing more than it’s shrinking. For every feature I implement I make note of things that I want to do to polish it (I want enemy health bars to have visual effects when they take damage, for example) and that bloats out the stuff that I need to do. Most aesthetic features are noted as ‘low priority’ so I don’t feel a need to rush on them compared to more important things like getting various systems implemented.

   I’m thinking that the next thing I tackle will probably be adding the player’s companion to the game followed by implementing proper victory/defeat screens in the combat loop. Past that? Who knows. Maybe some world building is in order. But before I do more building I want to fix doors being bugged…

Read More Fiancée Game – 06 – UI Work and Combat