C-C-C-COMBO SYSTEM! Part 1

Ok, now this is starting to look and feel more like a game. The combo system has been added to the game in a basic, minimum viable product sort of way. Just the minimal amount necessary to demonstrate the idea has been implemented. The code is still a bit of a mess and some refactoring is certainly in order but there are too many ideas to get out. Some other UX improvements have also been added.

Dragon Drop

The ability for a user to drag and drop (I prefer to call this Dragon Drop) cards during combat has been added, making for a much more fluid combat experience. Cards are now flicked at the enemy portrait in order to use the card. This flicking motion lends itself towards faster card plays which feeds into the combo system.

Combos

The idea is relatively simple, all cards are given a color and most cards have a Followup Combo Color. When a card is played and then the next card played is the color of the previous card’s Followup Combo Color the player’s Combo Points are increased. The player can continue to rack up combo points until the combo ends. A combo ends either through the use of a Finisher or by being interrupted. A combo can be interrupted either by the player not following up a card with a card that is not the Followup Combo Color or by being attacked by the enemy.

Finishers

Finishers are almost the same as Followup Combo Colors. Where most cards have a Followup Combo Color, many of them also have a Finisher Color. When a card with a Finisher Color is played and then followed by a card that is the color of that Finisher Color the combo is completed granting the player bonus damage and/or effects. The player’s Combo Points are then reset and a new combo can begin.

sweetCardArt
Early card examples showing card color, name, Combo Color and Finisher Color.

 

Next time we’ll cover how combos can be interrupted and all the terrible things that take place when that happens.

Better Map Generation, Auras and Deck Include Modifiers

Getting back into the swing of things with the project by first implementing Better Map Generation. Like I said in my last post, the world used to be generated totally randomly as a player moved around, causing Mountain terrains to be right next to Forests which are directly next to Tundras, basically all the terrain types where just mixed together.

But now, when a player moves into a new location, with no terrain tile associated with it. The game takes all adjacent terrain tiles into account before choosing one. This causes larger Biomes to exist, hopefully this will make the world seem less random and give some aspect of actually being somewhere in the world. Especially when I get around to adding biome specific events, enemies and effects.

This is just the first step in expanding the terrain generation mechanic, so we’ll see how that goes.

Next up, I started adding in Auras but quickly realized I need to refine the idea. The basic idea is that Auras give you special abilities, and you can only have 3 equipped at a time. These special abilities would give you additional choices during events or alter how some items work. At first I thought they might just be stat modifiers but I scrapped that idea because I was afraid it would move in on the Deck Include Modifiers idea.

So my plan is to leave Auras alone for now and return to them after implementing Deck Include Modifiers. What ARE Deck Include Modifiers you ask? This is a mechanic I’d like to add where including certain cards in your character’s deck result in your base stats being modified, as a means of balancing a cards power.

For instance a FireBall card might do a large amount of damage when played in combat, but simply adding the FireBall card to your deck will lower both your Max Hit Points and your Defence. The overall idea is that by adding certain cards to your deck you have some degree of control over your character’s “class”. Want to be a Mage-like glass cannon? Add in those fireballs and other powerful abilities at the expense of your health and defence. Perhaps add in Armor cards that have no effect when played in battle, but their Include effect raises your base defense so long as the card is in your deck, making you into a Warrior like tanking class.

These are just off the top of my head, so there will probably be many changes as I start to add it in. Which is exactly what I’m about to try to do!

Post-Contest Hiatus, Planning and Card Art

The Break

I’ve been on a break from further development for the past month. Various reasons for the break including just being busy, freelance design work and playing too much Civ 5, DOTA2, Card Hunter and Android:Netrunner.

The World

One thing that added to the stall was trying to come up with the right way to proceed with the World Generation. The current way the world is generated in Nano is not very apparent to the player. But here is a summary of how it works:

  1. A player enters an x/y location, either through moving to that location or their initial spawning (which places them at 0x 0y.
  2. The game checks to see if a terrain piece has already been set to that location.
  3. If there IS a terrain piece saved to the player’s location, then that terrain piece is displayed to the player.
  4. If there is NOT a terrain piece saved, the game randomly rolls to see which terrain piece to use out of all terrain pieces in the database. Then that terrain is saved to that location and any player entering that location will find that terrain piece.

While this was very easy to implement, it also is very rudimentary and does not allow for the inclusion of Biomes. Ideally, if a player was in a Thick Forest terrain, then they moved 1 position they would still be in a Forest biome and hence get another forest type terrain piece generated for them. This would continue until the player came to a transition piece which the game would place semi-randomly (it would take into account the adjacent terrain which would affect the probability of the player’s location being generated as a transition piece). Once a transition piece has been placed, adjacent, undefined locations could be from any other biome.

Basically, this would make it so a player wouldn’t be in a forest one second, a mountain the next and then a desert after that. Hopefully, implementing biomes would make the world of Nano seem more realistic, with various Forest terrains adjacent to each other, as with all other biomes.

This however is much harder to implement and there are many ways to achieve the desired effect. I looked into a variety of procedural generation techniques which use height maps or Perlin Noise. But these methods seemed a bit too complex for my needs and it would also mean more terrain would be generated than I needed, if I was to generate terrain only on a character’s movement.

Another option was to simply create the game world manually. This has the benefits of being easy (no programming needed) but would limit the size of the world and would make the world less dynamic.

So, my current plan is to do something similar to transition piece idea, mentioned above. I’ve yet to begin implementing it but I think that will achieve my goal best without being overly complicated.

The Art

I’ve got new card art! Ashley Kuros has been a friend of mine for a long time and she is a talented artist. She has been nice enough to offer her help with the art needed for my game! So far she’s provided a bunch of pieces to be used with the various cards you can find in Nano. Below are a few of the pieces provided by Ashley already implemented in Nano and I hope she’ll continue providing more!

Punch Sand in your eyes!

Warm Up
Warm Up
Debilitating strike
Debilitating strike

True Deck Validation, Card/Combat Reconjigger, Additional Content!

True Deck Validation, I was being dumb

Last post I started out boasting about how I implemented Deck Validation, but then as I was writing the post I realized it didn’t work at all. Well this time I actually DID make Deck Validation work, by avoiding the problem altogether. Take THAT last post!

So originally I came up with this way of having the deck get checked for its validity after a change was made. Oh and just so you know, an invalid deck is one which has less than 10 cards in it, for now atleast, I may increase the minimum deck size later. But anyway, I quickly realized this was the wrong way to go about it, as a deck could be made invalid (remove all the cards) then the player could just leave the game entirely by closing the browser, upon returning to the game they would be back in the world, with an invalid deck, ready to blow up my game the moment they enter combat and have no cards to draw! Hell no am I letting some deckless weirdo blow up my game!

So basically, I just made it so you could never go below 10 cards, if you try to the game doesn’t apply your change, warns you of such and tells you to add a card before removing one, easy. I wish I thought of that at first.

Making Cards and Combat not suck

After that it was on to making Cards and combat a bit more interesting. Problem was, until now, cards could only make 1 stat change. That was fine when I only have cards like Punch and Kick that do x amount of damage to the enemy, but if that is the most any card can do then the game will get boring really fast. I’m bored just talking about it, so I set out to make more complex card interactions possible.

Cards are now made up of 2 objects, Card and CardEffect, in a One to Many relationship. One Card can have many CardEffects. Each of these effects can have a different target, effect different stats and for different amounts. This allows for new cards such as Thrash, which does a large amount of damage to the enemy, a moderate amount of damage to the caster and lowers the caster’s Defence stat. Complexity, Fun!

There are many other cards like this and I intend to balance a cards with positive and negative effects to make each choice one of risk vs reward. Hopefully this will make combat more interesting. I have more ideas for making cards have interesting effects, even having them affect the character outside of combat!

Speaking of combat, since I changed around how cards work, that meant that I had to go back and refactor my combat methods. This took a while but it really needed it, since I’ve learned so many better practices since first coming up with my combat methods. I still have to add in text generation but that shouldn’t be too hard… (famous last words).

Filling out the games content a bit

Lastly, I’ve greatly improved the workflow involved with adding content to Nano. This is something only admins like myself would ever interact with, but adding content has been something I kept putting off simply because the only way to do it was via SQL statements. Well not anymore! Now I have nice forms that I can fill out and drop down lists with all my enums. Just the other day I added 20 cards and all their effects. Next will be enemies, consumables and events!

So, things are working out pretty well, and I think I’m still on track to have Nano ready to present at DevelTeam’s game jam. Only thing left that I haven’t thought about is how to host the game. I originally planned on just hosting it on my own computer and leaving my comp on for a few days and giving them an IP address, but I’ve started to look around and it seems I can get some temporary hosting setup and just use that for the contest. Better figure that out soon!

Deck Validation and DevelTeam.com Contest

I’ve added ‘Deck Validation’ and it was easier than expected. Pretty much any time I implement something and it works right off the bat I consider it “easier than expected”, perhaps I’m a bit of a pessimist when it comes to my programming skills.

Anyway, I’ve set it up so that a character’s deck must consist of at least 10 cards, any less and the player will be shown a warning message, telling them that they cannot leave the inventory screen without adding more cards…

Actually, now that I think about it, there are plenty of ways to get around this, most likely by accident… hmm, how to deal with this then…

Well, the basics are there, I suppose I’ll just have to check deck validation in more places to cover this.

DevelTeam.com Contest

DevelTeam.com is having a contest for indy games/developers. I’m going to try to enter Nano into the contest, but the deadline for submissions is mid/late august and I can only hope to have the game functional by then, it probably won’t be much fun. I’m more interested in getting some people to notice it and maybe get some other developers and artists to want in on the project. The contest is offering a handful of quality game (most of which I already own) but I’m not terribly interested in winning (I’m sure I won’t win with Nano in it’s current state).

If I do get the game into the contest, I hope people will be receptive to the game in its current super-early stages.

Implementing Events 2 – Expanding and Frequency

There is still more to be said about Events so here is part 2!

Expanding the Events Feature

If all the game did was pick a random event from a pool of every event, the world wouldn’t seem very… alive…duuude. So, some events should only happen in particular climates (I call them Biomes). For example coming across a pool of water might be something that can happen in any biome but an event like “Falling Tree” might only happen in a Forest biome and not in a Plains biome.

To allow for this Events have a Biome, Terrain and hasPriority property. When the game’s engine creates the pool of available events to choose from it grabs all events that can happen in any biome as well as the events that can only happen in the biome the character is currently in. So a character in a forest biome, Big Tree terrain would have an event pool that contains events that can happen in Any biome, in the Forest biome specifically and events that can only happen in the Big Tree terrain tile.

The hasPriority property is only used if a certain event should always be used in a given terrain tile. Such as a Throne Room terrain tile in a dungeon should always have a boss encounter. That event would then have it’s Terrain property set to ‘Throne Room’ and hasPriority set to True (as that variable is a bool).

Event Frequency

There is also a Frequency property to each event and event reward. This number give some measure of control over which events are more common over others. Not too much to say about that one really. While the concept is fairly straightforward, implementing it was not so simple. So here is what I did:

After creating the initial Event Pool, I had a list of possible events. I then added together all the event’s Frequency properties. I used this number as my MaxRandom number, the maximum number the game could roll when picking an event from the pool. I also made a second list called the Event Pick List which only had 2 properties: Event and SlotID. This list was then populated with a number of entries for each event equal to the event’s Frequency. So, an event with a frequency of 10 would have 10 entries in the Pick List. The engine also applied SlotID numbers in sequence.

For Example:
An event pool with 3 events:
A Pool of Water (Freq. 10)
A Falling Tree (Freq. 5)
Strange Mushrooms (Freq. 5)

MaxRandom = 20 (10+5+5)

Pick List:
A Pool of Water (slotID = 1)
A Pool of Water (slotID = 2)
A Pool of Water (slotID = 3)
A Pool of Water (slotID = 4)
A Pool of Water (slotID = …)
A Falling Tree (slodID = 11)
A Falling Tree (slodID = 12)
A Falling Tree (slodID = 13)
A Falling Tree (slodID = …)
Strange Mushrooms (slotID = 16)
Strange Mushrooms (slotID = 16)
Strange Mushrooms (slotID = 18)
Strange Mushrooms (slotID = …)

Then the random number is picked between 1 and MaxRandom. The number picked corresponds to the Pick List’s slotID and that is the event assigned to the character.

With some form of filtering being applied to the possible events and then frequency being taken into account to allow for common/rare events, when a character encounters an event it will hopefully feel more meaningful.

Implementing Events Part 1 – Being Stateless

I’ve started implementing the Events feature into Nano. So far my posts haven’t been too technical or in depth, so this one might be a bit heavy for some. First, allow me to describe the overarching idea behind Events in Nano.

The Idea

As a player navigates the world they occasionally encounter an Event upon entering a new location. An Event is basically a description of something that is happening and a list of choices about how to react being made available to the player. Once the player has made a choice they are given some type of result, such as stat alterations, finding treasure, or getting into combat with an enemy.

Example Event

A player enters a new location called ‘The Open Plain’. Upon entering this location they are shown an Event screen, for the event ‘A Pool of Water’. This event has a description; “You see a pool of water. It looks clean enough to drink.” and a couple of choices:
Choice 1: “Drink the water.”
Choice 2: “Ignore the pool of water, bugs have probably pooped in it.”

The player selects Choice 1, “Drink the water.” (Ignoring the possibility of bug poop!). This choice results in the character’s Thirst being reduced by 100. Had the player ignored the water, they would not have received that reward. A second screen is displayed given both a description and a breakdown of the results.

“You drink the bug poop free water. Ahh, refreshing!”
Thirst: -100

How to Organize the Data?

So now that we know the overall idea of what we’re trying to do. How do we execute that in code? It’s never as straightforward as you think and even when you’re prepared for it to become complex, it’ll go and get even more complex than that. This is because at this stage of development I’m really building a system, not just a ‘if this, then that’ scenario.

How does the database look?

First I had to figure out how to organize the information in the database. Will the events, choices and rewards all be in one table or would it be better to have a separate table for each event element?

After a lot of thought, I decided on having separate tables for Events, Event Choices and Choice Rewards. The reason is that each of these has a One-to-Many relationship with the next. For example an Event has many Choices and each Choice can have many Rewards. This would suggest that using a separate table for each piece would be the best way to manage them.

Being Stateless

One major pain that I’m always dealing with in this project is that as a web game using MVC4 and standard postbacks (ie. I’m not using Flash) is that this game is Stateless. Most games can save information about the player’s current location, stat values, and what screen their looking at in your computer’s memory, but not Nano. Nano needs to save all these variables in a database and access that database after every player choice.

Being Stateless Allows Cheating

So given the Stateless limitation, how does the player’s choice get sent back to the server? Another problem with being Stateless is that user input cannot be trusted, they could send any value they want back to the server and the server just accepts that value, never thinking that the user might be a big fat cheater! For example, if a player is in combat and clicks the Use Kick button, the link they click actually forms a URL that ends in /UseCard#CardID=3 which calls the UseCard method with CardID=3 (3 being the ID # for the Kick card).

So there you go, that’s how you can try to exploit Nano. During a combat just change the url to have the CardID equal a number of an amazing card like ‘Sword of a Thousand Truths Stab’ and you can use that card even if it’s not in your hand or even in your deck!

Just kidding, you can’t do any of that because I had to take special measures to stop that form of abuse. Again, because the game is stateless, when the user sends a request to use a card with a particular ID I first check to see if that card is in the user’s hand. If not the user will get a message saying it’s an invalid card and then it will taunt them for trying to cheat. But the point is, this is something many games don’t have to be concerned about since they can store information in memory.

Record the Character’s Current Event

Something that is nice about working in this Stateless environment is that it allows the player to leave the game at any moment and when they return they will be right back where the left off. Whether that is standing in the middle of a forest, at a crucial choice for an event, or right in the middle of combat.

But this also means that the game must record everything to allow for this seamless return. For Events, I decided to add a property to my Character records called ActiveEvent this field stores the ID# of the event that the character is currently involved in. Upon page load the game says “Is the character in an event?” If no, then the ActiveEvent field is null and the game displays the location the character is in. If yes, then the game looks up which event it should display based on this ActiveEvent field.

Sum it up

So that’s how working in a stateless environment for a game adds a layer of complexity to the design of the game. I have to think about everything in steps and each step has to end in a single output of information for the player to react to. In the next post I’ll get into making events more interesting by limiting their frequency and availability.

Basic Survival and Character Score Added

Survival

You’re wandering around a forest. You’re don’t know where you are, but you aren’t lost. Where you are isn’t something you are concerned about, but where you are going to get your next drink of water, or bite of food is.

I’ve added some basic ‘Survival’ mechanics to Nano. As you move from location to location you gradually build up Hunger and Thirst. Meat and Water Jug consumable items have been added to sustain your character. If a character reaches a certain hunger or thirst threshold they will begin taking damage whenever they move to a new location as they slowly dehydrate or starve to death.

Currently the only way to get your hands on Meat or a Water Jug is to win a random encounter with an enemy, and then hope that enemy drops the consumables. This is causing a bit of an issue because there is currently only a 10% chance a character will get into a random encounter, and on top of that there is an 20% chance the enemy will NOT drop a consumable. Meaning, consumables are fairly rare, while starvation is common. It’s like a virtual 3rd world country.

So next up is adding more sources of food and water. One thing I plan on adding is environmental sources of sustenance. Rivers, streams and lakes that provide water, and edible plants to reduce hunger. I hope this will keep vegans off my back as well.

Score

I also added some simple Scoring mechanics. Currently, a player is awarded points for every combat encounter that they win. The value of the combat is determined by the type of enemy encountered. Soon I’ll be adding more ways to up one’s score, such as points for discovering new locations, or perhaps acquiring hard to get items.

The idea of having character’s maintain a score is that eventually there will be a leaderboard. Where players can compete to be top dog. Aside from that I’d like to have a character history page. A page where a player can go and see all of his/her old, deceased characters, along with the character’s score upon death. This will allow players to try to beat their personal best score as well as compete against other players.

Weekend Update 05-12-13

Some updates from this weekend:

  • UI improvements for the World screen. It still have a ways to go, but it’s a start.
  • Random Monster Encounters! Characters are now hurled into combat randomly when they enter a new location.

Probably going to need to reconjigger Cards and combat again to make room for more complex card interactions. I’d like to avoid making a separate method for each card, but I think some cards will require it.

Thinking about making more complex card interactions means I might have to step my AI’s game up. Perhaps that is where I can begin implementing the learning AI I’ve been wanting to experiment with.

I need to add a lot more content, more Cards, Enemies, Terrains, Items, etc. I’ll make a form that I can use to easily add those things to the database.

I hope to have a veeeeery early build “playable” in a few weeks, if anyone is interested in trying out what I have so far.