Check the facebook page!

If you prefer, you can also follow the Facebook page for this blog :)

Wednesday 28 May 2014

Glitches, Bugs and Exploits

Today I decided to talk to you about glitches, bugs and exploits. I will try to tell you what they are, what could cause them and some examples. For that though, I will need to go a little bit into detail about programming and whatnot, but I'll try to make it understandable for everyone!

I'd also like to thank the person that suggested that I talked about this :P

So let's get started!




So, what are they and what are the differences between them?

There are many definitions for all of those, but in my opinion, the main difference is what causes them (asides from exploits which I'll explain shortly).

Note: There are many types of these errors, I will name a few but there are many others.



Glitch occurs more "randomly" and can be caused by many things but mostly through some kind of interaction of the game's mechanics.

For example, a common glitch in many games is when you go through walls/ceilings/floors or any kind of "solid" object.
Let's move on to programming for a bit, collisions in the video-game world are not like in real life, obviously, walls are not physical objects on the game world, heck, nothing is, but you still can't go through them... usually. So how do they work?

Your character (and every object you can interact with) usually have what's called a hit-box, which is an invisible rectangle (or any shape) that is used to detect collisions, walls (for example) also have that.

So, when your character is walking towards the wall, the key you are pressing is telling the game "move in X direction at Y speed", this happens constantly while the key is pressed, the code is going through itself thousands of times per second, each time a "loop" occurs, it sees that you are still pressing the key so your character stops moving.
However, when you reach a wall, that "hit-box" will touch the wall's hit-box, the code will detect this, so what do you think it does? No, it does not tell the code "stop moving", why?
Because if it made your character stop moving, when you tried to move in the opposite direction you would not move because the hit-boxes are still touching each other, and so is the instruction to "stop".

So what actually happens is, when you touch the wall, the code detects this and moves your character AWAY from the wall, but since this "nudge" is so small and it happens thousands of times per second you don't even notice it.
Here is a crude drawing I made:
Notice that the character isn't touching the wall.




Ok so now you understand more or less how collisions work, right? (You can always ask if you didn't)

So, imagine you place your character in a corner, and let's say your character can throw some kind of item or skill that creates a solid object. If you throw it close to your feet, that object would push you away from it, but this would also push you into the wall which would in turn push you back against the object.

If you threw more of those objects you would have more force acting upon your character and it would be shaking like crazy (because it was being pushed in many different directions at the same time) so eventually, the force would be so great that your character would glitch through the wall, in other words, pass through it.

I call this a glitch because there's not exactly anything wrong with the game's code or anything, but by doing certain things you cause everything to go into conflict and make things that shouldn't happen, well, happen.

That is an example of a glitch, more on this example later.



Bug is an error or mistake in the code that makes thing happen or not happen when they shouldn't or should.

For example, imagine if on the code for the in-game store, the programmer said (this will be code "translated" to english, it isn't really like that obviously :P) "when the _player buys a Wooden_sword subtract 500 _Money", however, when they created the "_Money" in game they used a lower-case "m", in other words "_money" so depending on the programming language, they might have not gotten any errors with that, but of course things aren't working well.

What this example says is that, if you bought a Wooden Sword, you would get it but not lose any money, because the code is subtracting to a non-existential variable, which would be created at that point since it didn't exist.

In other words, let's say you had 5000 "money", you go to the store, buy a Wooden Sword and your money would still be 5000. However, invisible to you, a variable named "_Money"  would now be -500... and -1000 if you bought another one.



Now for the exploits (that link is more related to computer exploits but it's the same general idea).

An exploit doesn't exist by itself, it is basically a Glitch or a Bug that you can use for your own advantage.

For example, recall that wall glitch I mentioned, you could use it to pass through a door that had treasure behind it but you still didn't have the ability to open, or it can let you take shortcuts, cut maps or anything like that.

An example for that is in Castlevania: Symphony of the Night, if you use a certain technique before talking to the Librarian (the one who sells items and buys jewels), you can open the menu while talking to him.
So you could go to the "Sell gem" option, and let's say you only had 1 diamond (the most valuable gem), on the selling part you would only be able to select 1, but if you opened the menu (because of that glitch), equipped the diamond, and then sold it, what would happen is that you would get a stack of 255 diamonds!

Why? I'll explain.

The game doesn't count the gems you have equipped, and if you only have 1 but you equipped it, in the store it counts as you having 0, but since you equipped it after the store counted 1, after you sell it, it would subtract 1 to 0... Since the Diamond number can't be negative, it loops back to the highest value for that variable, which is 255 (the 0 also counts as a number, so 256 is really the max number).

This is an exploit because you can use it to get all the gold you want in that game.


The same thing can go for bugs and for my example.

You can buy as many wooden swords as you want (since it will never deduce your real "money") and then sell them back for real "money" (assuming the code is correct on the selling part).

Types of Glitches/Bugs

Lastly, there are a few different types of glitches/bugs and I'll name a few...

Game-breaking: These are the worst kind and as the name implies, the make it impossible for you to play the game as you should, some examples of these are bugs that prevent you from finishing an important quest, forcing you to stay in a kind of "limbo" where you can't proceed.

Or for example, a bridge you need to cross to get to the next area doesn't have collision detection on it so you just pass through the bridge (not allowing you to cross it), etc.

Texture Glitches: These are usually the fun ones, when character's heads turn upside down or when corpses look like they're having a seizure.
Unless, of course, this messes up your whole screen obviously, if it prevents you from seeing clearly or anything like that then they might be more serious.

Neutral: These are the ones that neither help nor hinder you, some texture glitches for example.

Fatal: Those that screw up your machine, like if the game somehow tried to divide by 0 and there's nothing in the code that prevents that... it would probably crash your whole game :P

Exploitable: These are the glitches that you can use for your advantage, such as the examples above.





And that is what I can come up with at the moment, if there's anything else you'd like to know or me to explain feel free to comment/email me/whatever.

Thanks for reading :)


Cheers!

4 comments:

  1. Mad paint skills!

    ReplyDelete
  2. Do inanimate objects have hitboxes, or not?

    ReplyDelete
    Replies
    1. Depends on what you want to do with them. If they are just for looks, background, foreground, props etc. You don't need them.

      But if you want to be able to hit them, stand on them etc. you kind of need them.

      A hitbox is basically an area that checks if anything is touching it, if it is, something happens.

      For example, if you want to only damage the enemy by hitting its head, you only put a hitbox on its head. If your attack's hitbox touches that hitbox, it performs the appropriate instructions, in that case, cause damage.

      Hope I cleared that up, if not feel free to ask any more doubts you might have :P

      Delete

What do you think or want to share?