Explore Free Construct Tutorials – GameDev Academy https://gamedevacademy.org Tutorials on Game Development, Unity, Phaser and HTML5 Sat, 25 Feb 2023 21:14:35 +0000 en-US hourly 1 https://wordpress.org/?v=6.1.1 https://gamedevacademy.org/wp-content/uploads/2015/09/cropped-GDA_logofinal_2015-h70-32x32.png Explore Free Construct Tutorials – GameDev Academy https://gamedevacademy.org 32 32 The Complete Construct 2 Course – Build 60 Games https://gamedevacademy.org/the-complete-construct-2-course-build-60-games/ Wed, 02 Nov 2016 12:25:04 +0000 https://gamedevacademy.org/?p=4011 Read more]]> Yes, you can learn to build games in Construct 2 without coding. Master game development by building 60 practical projects from the ground up including art. Don’t waste precious time learning a bunch of useless coding practices. This is a project based course designed to get you from point A to point B fast while giving  you immediately employable skills.

Construct 2 is a powerful ground breaking HTML5 game creator designed specifically for 2D games. It’s great for beginners because it allows anyone to build games — no coding required!

Access this course on Zenva Academy

 

]]>
The Ultimate Game Development Course with Construct 2 https://gamedevacademy.org/the-ultimate-game-development-course-with-construct-2/ Sat, 25 Jun 2016 11:00:19 +0000 https://gamedevacademy.org/?p=3829 Read more]]> Are you wanting to build games but have limited programing experience? Then this is a course you must take! And for a limited time, it’s free! Learn how to build games using Construct 2.

Construct 2 lets you build complex 2D games of all kinds by simply dragging and dropping blocks and elements. After building your game, it is easily exported to HTML5. Then you will learn how to upload it to the Amazon App Store and have access to millions of potential players.

Access this course on Zenva Academy

]]>
Free Construct2 Ebook https://gamedevacademy.org/free-construct2-ebook-level-zero/ Wed, 02 Dec 2015 01:08:01 +0000 https://gamedevacademy.org/?p=3127 Read more]]> We are happy to announce the release of Level Zero, an awesome Construct2 ebook created by Ankur Prasad and Allen Wu and aimed at complete beginners.

This free Construct2 ebook covers the creation of 5 fully functional games built with this great tool, and will take you from absolute newbie to having made a few mini games for your portfolio.

This fantastic book covers all of Construct2’s main features and gives a very comprehensive view of what can be achieved with it!

Download the ebook (80 MB)

Book authors

ankur-prasad

Ankur Prasad

An expert in the game industry. Ankur has worked at Microsoft and currently resides at Amazon as the head of partner marketing.

allen-wu

Allen Wu

Founder of Wu Tango Media, an app development firm that’s published 58 mobile games with more than 3.5 million downloads.

Level Zero is hosted at Zenva with the  permission of the book author Ankur Prasad, you can also buy the Kindle edition on Amazon

]]>
Able Game Development #2 – Re-mappable Keys https://gamedevacademy.org/able-game-development-2-re-mappable-keys/ Wed, 25 Jun 2014 20:53:43 +0000 https://gamedevacademy.org/?p=2055 Read more]]> Hi everyone! I’m in the mood of writing tutorials now so why don’t we continue our able game development series! This is the second part after at the first tutorial I talked about adding another control configurations for your game to accommodate people with disabilities. This time I’m writing about remappable keys! If in the last tutorial we added another key to move around with WASD, now we’re going to do a similar thing, but the player will be able to decide the alternate keys. (this tutorial was first written in my blog, in Indonesian)

How to do it in Construct 2? First make a new layout and make something like a platformer level, we’re going to base this tutorial on a simple platformer.

pic5

The blue sprite is the actor with a platformer behaviour, the green sprite is our platform with a jump-thru behaviour, and the grey one is a ground with a solid behaviour. By default this game is a simple platformer, now we’re going to add the remapping feature. First, add a remap button (here, on top left corner but you can add it anywhere you want)

pic6

then add a new layout, this is where we’ll remap our keys.

pic7

those three sprites are for changing / remapping our keys. To know how to do that we’re switching to code view now.

pic8

first declare all the needed variables. Some of these variables are for storing the keycode value of the new keys, others are for the remapping functionality.

pic9

the next block of codes are the remapping function. We will first add a text “Add a key to remap” then the game will remember the keycode of the next keyboard button the player presses. The question is: How does the game know which control to remap to the next press of a button? This is why I use the isRemapJump, isRemapLeft, and isRemapRight variable. The game will remap movement for the variable which value is 1 (or True). There’s one more variable I want to explain: isRemapping. It is used to prevent players from clicking two buttons first before pressing a keyboard key, which can make it confusing to decide which control to remap.

Lastly, we’re going to use the Keyboard object to remember the keycode that is pressed.

pic10

And now we’re almost done! We just need to go back to layout one to use the keycode the game just remembered.

pic11

there, done! We added new instant variables to actor object and use them to move it around. If you feel like familiar with the code, that’s because this code is based on the one we used in the previous tutorial. We just develop it a bit further to make the players able to define their own configurations.

I think that’s enough for this tutorial, if you want to grab the project file it is here in my dropbox. Until next time!

]]>
Able Game Development #1 – The Control https://gamedevacademy.org/able-game-development-the-control/ Mon, 16 Jun 2014 15:29:27 +0000 https://gamedevacademy.org/?p=2022 Read more]]> Hi there everyone! It’s been really a while since I last write a tutorial here, the last time it was a series of RPG tutorials. Now I feel like I want to write another series of tutorials, this time I called it able game development. What is this? It’s about designing and making a game that those with disabilities can enjoy as well. I’ve actually wrote about it on my own blog, but I thought that I’d share it here as well.

I want to state this clearly first, that these designs are purely optional. You’re free to include this in your game or not, but by including it will make those with disabilities to enjoy the same kind of entertainment that you do too. The resources and ideas for these series are taken from other site. They have a really good documentation about many kinds of disabilities and what we can do as developers to implement them in our game. Here, I’ll try to implement them using my weapon of choice, Construct 2.

First we’re going to make game design that caters to people with mobility disability. This kind of disability hinders their movement, preventing them from doing tasks that for us are simple enough, like playing with two hands. People with this kind of disability are the largest in numbers among the disabled people, if your game can help them play a lot of people will thank you.

The first design element that we’ll discuss is alternative configuration. This is simply various other control configurations beside the default one that the developer has created so players can just pick one that is most comfortable to them according to their disabilities. There are at least three different configurations here: default control, right handed control, and left handed control.

If you’re playing your game try to play it with one hand only, either left or right hand. Can you still play it? What buttons can you reach with only one hand? This is how you simply test your game. Now let’s move on to how we’re going to make it in Construct 2.

First add two more objects: Keyboard and Sprite. Rename the sprite into “actor” and add an 8 direction behaviour.

8 direction behavior

change the default control property to “no” so actor can’t move using default arrow buttons. We’ll allow him movements with arrow key buttons later, we’re doing it this way to demonstrate the alternative configuration functionality. After that add these variables:

 

global variables contruct 2

Those are the variables we need to move our actor. Two constant variables TRUE and FALSE are created to make our code easier to read. Then how do we move our actor? Using the code seen below:

contruct 2 config

Now we can move as if we’re using the default control, next up we’re gonna add other buttons to accomplish the same task. How? see the piece of code below:

other construct2 configurations

We just added a new movement button configs, using WASD keys. It may look simple but for people who are unable to move their right hand, this additional control config makes it easier for them to play the game. You can develop this code further. If there are jumping or shooting ability in the game, what are other configs for those two actions? Can it still be played with one hand?

I think that’s all for the first part of this tutorial. Later we’re going to tackle other design decisions that makes it easier for people with disabilities to play our game.

]]>
Construct 2 RPG Series #6 – Mages AI https://gamedevacademy.org/construct-2-rpg-series-6-mages-ai/ Thu, 24 Oct 2013 11:04:16 +0000 https://gamedevacademy.org/?p=1482 Read more]]> Construct 2 RPG Series by Aryadi Subagio (@AryadiPS):

Welcome to my tutorial of making an RPG. This is the second part of designing enemy AI, the mages AI. Making AI for mages isn’t really much different than AI for physical attacker, there’s only little changes. First we need to remember that there are two kinds of mages, the offensive mage that attacks enemies with destructive magic, and the supportive mage that gives healing or any other supportive magic to allies. Both have their own logics.

First, let’s design the AI for offensive mages, the logic flow is like this:

  1. Select target
  2. If the SP is enough to cast at least one magic, choose a magic
  3. Enter casting time
  4. If attacked by enemy, the magic is cancelled
  5. If casting time is finished, reduce the SP and cast the magic
  6. If target is still alive, back to no. 2
  7. If target is dead, back to no. 1
  8. If don’t have enough SP, attack physically.

The last point is needed so that the magician don’t just stand helplessly on the battle screen. The logic for selecting target is the same as physical attacker, we’ll be using instance variables enemySelection and targetName. If you forget what those are, please see my previous tutorial, it’s written there so I’m not going to explain it again.

Next, the mages will select which magic he/she will cast. For now I’m making the enemy select the magic randomly from the list of magics that are available to him in one battle. Because I don’t know how to make the AI to choose a skill/magic over the other, when I know how to make it, I’ll write a tutorial about it. After choosing their magic, the mages will enter a casting time, while casting the mages can’t walk or attack or do other things. If you still remember the state instance variable, we will change the value of the state variable while the mages are casting the magic. All magics have an instance variable called castTime that determines how long the casting time is in seconds. If the mages are attacked, we will change the state so we know that he’s not currently casting his magic. If the casting is finished uninterrupted we will reduce the SP and then execute the function that will cast the magic. I’m planning of making a family that contains all available magics and have the necessary instance variables and functions, including the function that will cast the magic.

Now on to the supportive mages AI. These mages have two jobs: to heal the wounded party member, and to give magics to temporarily boost stats. So the flow of logic is: if there’s a friend needing healing heal him, if not then give supportive magics.

  1. Look other party member’s current HP, find if there’s someone need healing
  2. If there is, choose a healing magic
  3. Enter casting time
  4. If attacked by enemy, casting time will end, and magic won’t be casted
  5. If manage to cast the magic until finished, reduce current SP and cast the magic
  6. Back to Point 1
  7. If noone need healing, choose a supportive magic
  8. Choose a target for the magic
  9. Enter casting time
  10. If attacked, casting time will end, and the magic cancelled
  11. If manage to cast the magic, reduce current SP and cast the magic
  12. Back to point 1

Before executing this AI, we need to check whether the current SP is enough to cast at least one magic, if unable then the mage will do physical attack.

The definition of  “a party member needs healing” is interesting, and we can customize this to determine how often a magician will heal his or her party member. I’m gonna divide this depending on how much is the other party member’s current HP. Just like usual I’m gonna make an instance variable of it, this time I’m naming it healMethod.

  1. Heals when other party member’s current HP is below 75% = “worries”
  2. Heals when other party member’s current HP is below 50% = “moderate”
  3. Heals when other party member’s current HP is below 25% = “critical”

with this we can customize party member’s (or enemy’s) healing AI for the healer, because I want the AI customization to be a little bit advance. One more note about healing magic: there will be healing magic that heals more than one party member, and to use it healers must know whether the wounded party member is only one, or more than one. For this reason we’re gonna make an instance variable called woundedNumber. If the value of woundedNumber is more than one then healers will use healing magics that heals multiple party members at once. This value will be set back to 0 after each use of healing magics.

For supportive magics, we need to mark whether a character’s (or enemy’s) party member has already casted by a supportive magic or not, so that the magician will focus on supporting a character that hasn’t been casted by a supportive spell. We’re gonna make two kinds of slots, for buff magic and for debuff magic. These slots are instance variables in the name of: slot1Buff, slot2Buff, slot1Debuff, slot2Debuff which contain the string of name of buff/debuff magics casted on the player.

That’s it for now, next time we’ll start on implementing this AI.

]]>
Construct 2 RPG Series #5: Designing the Battle AI https://gamedevacademy.org/construct-2-rpg-tutorial-designing-the-battle-ai/ Mon, 07 Oct 2013 12:31:16 +0000 https://gamedevacademy.org/?p=1426 Read more]]>
  • Construct 2 RPG Series by Aryadi Subagio (@AryadiPS):
  • In the last tutorial I made a (very) simple AI for enemies, even though the end result is just the enemy following the character around. Before I make the AI in much more complex code, I want to design it first. And even though this example is for enemy’s AI, the code can also be used to make an AI for our party member. AI for boss enemies will be the same, the only difference is in the value of parameters (or variables).

    There’s gonna be a short range attacker and long range attacker in either enemies & player’s party member, there’s also gonna be a physical and magical attacker. So, based on the type, there are several types of fighting characters:

    • Close range physical attacker
    • long range physical attacker
    • Magical attacker
    • Healer / supportive

    There is only one magical attacker because magicians can attack from close or far away, and it wouldn’t make much sense for a close range magical attacker, since he can be attacked while casting. Each physical attackers will have an attack radius that will differ between close range and long range attacker, attackers will move so that the target is in range before attacking. Magical attacker don’t need to move closer to the target, because the magic’s range is the entire battle field. But magics will have a casting time and magicians can be freely attacked while casting.

    So how are we gonna make the AI? I’ll treat physical attacker’s AI differently than magical attacker’s AI. This is the logic process of physical attackers:

    1. If don’t have a target, look for enemies
    2. Move closer until target is in attack radius
    3. Attack target
    4. Decides whether defending or not
    5. If the enemy is still alive, back to no. 3
    6. If the enemy is dead, back to no. 1

    That’s the rough design of the AI, these still need further designing. For example no. 3, when attacking the target will the attacker use normal attack or skills? And if I design the AI this way, I can make some customization to the AI (so the player can assign different AI to party members). I’ll discuss these 6 points as we go.

    All attackers have an instance variables called radius, if there’s any target within this radius then the attacker will look for targets. To do this all battle participants have to know about the opposing party members (player party members know who are in enemy party members, and enemy party members know who are player party members). There are two ways to do this, one is to add instance variable to both party members which contains opposing party members, two is make a new family that can then be read by everyone in battle. Because both parties can read the data about their enemies at any time in battle, I’m gonna make two families that contain data about the member of enemy party and player party. This is more efficient than updating instance variable, for me.

    There are few logics that we can use to determine the attacker’s target, such as:

    1. The closest to the attacker
    2. The farthest to the attacker
    3. The one with most current HP
    4. The one with the least current HP
    5. Always attack magicians first

    Each attacker will have to remember their own logic of selecting their target, and for that reason we need one more instance variable for storing target selection logic. I will call this instance variable enemySelection and will store string values. To store target selection logic, these logics need to be represented in a string variable, like this:

    1. Closest enemy = “closest”
    2. Farthest enemy = “farthest”
    3. Enemy with most current HP = “strongest”
    4. Enemy with least current HP = “weakest”
    5. Attack magicians first = “mages”

    this will make it easier for us when we write the code.

    And then after we decide how the attacker select its target, the attacker will move closer to its target. Surely the attacker have to know which one is their target, and don’t change their target until the target dies. So we need another instance variable, we’re gonna name it targetName which contains the name of the target. But there’s a problem: what if there’s more than one kind of enemy in the enemy party? What if there are three yellow wolf in a battle scene? Which one will the other party member targets? To solve this we’re gonna give another instance variable in the enemy family called  battleName that contains string such as “yellowWolf1”, “yellowWolf2” and so on, the battleName’s value will be determined at the beginning of every battle.

    The next step is to attack, this can be a normal attack or a skill. Each attacker will have a different percentage between a normal and skill attack, some will use normal attack more often others will use more skill based attacks. It’s just like the logic for choosing target, I will represent each logic with a string and store it in an instance variable, we’ll call it attackMethod. The logic for attacking are:

    1. Normal attacks only = “normal”
    2. Use a little skill based attacks = “few”
    3. Same probability of normal and skill attacks (50:50) = “balanced”
    4. Use more skill based attacks than normal attacks = “frontal”

    Each attack logics have its own percentage between normal attacks: skill based attacks, which will determine the attacks. Of course, in case of skill based attacks, we will first check whether or not the attacker’s current SP is sufficient for the attack, or else it will be a normal attack.

    The last step is to determine whether the attacker will defend or not. The enemy doesn’t actually have to enter defending state (so that the player can easily attack them), but I add defending probability to make some enemies more challenging. It will be the same as attacking logic, we’re gonna store the defending logic in an instance variable called defenseMethod. The defending logic names are:

    1. Not defending at all = “defenseless”
    2. Might be defending = “defensive”
    3. More chance of defending (50:50) = “defender”
    4. Almost always defending = “guardian”

    If the attacker decides to defend, it will go into defending state for two seconds, before returning to the logic flows we made at the beginning.

    Well, that’s all! I actually want to write about magicians AI as well, but this one post has been a long one, so I’m gonna write it next time.

    ]]>
    Construct 2 RPG series #4: Basic AI https://gamedevacademy.org/construct-2-implementing-ai/ Wed, 02 Oct 2013 11:46:53 +0000 https://gamedevacademy.org/?p=1410 Read more]]>
  • Construct 2 RPG Series by Aryadi Subagio (@AryadiPS):
  • Before I go on about making a simple AI, let’s take a look at how the character attacks. If you look at it closely when the player press K repeatedly (or attack button on the gamepad), the character will attack without stop. I want to prevent this because attacking without stopping will make the gameplay becoma a button mashing type. Add an instance variable called attackCount (a number) to the Friendly family, so that this limitation will also effect the other party members.  And then at the event where charaAttacks function is called (where button K is pressed for example), add 1 to the attackCount of the character. Maybe you’ll ask: why not add the attackCount inside charaAttacks function? Because doing that will make attackCount of other party members add up when one character attacks. To avoid that I increased attackCount of attacking character in the place that I’m sure it’s the controlled character who attacks. We’re gonna have to implement something like this at the event when other party members attack.

    add attack count

    After that we will add a Timer behaviour to family Friendly, this to make a little delay after the character finishes their attack according to their attackCount. This delay needs to be named for us to use it, I will simply name it “rest”, because the player is resting after delivering a series of attacks. Make a string constant variable with the value “rest”. Then add an instance variable named state to family Friendly, this is where we will give the value of “rest” to mark that this character just attacked consecutively.

    Make two events that handles when player enter “rest” state and when that state ends. The character will enter “rest” when their attackCount reach 3 (or whatever long you want the combo to be).  Here we start the timer with the tag “doneRest” for 1 second (or however long you want it to be), after the set time the Timer will trigger an OnTimer event, which can be recognized by the tag that we gave it. We will end the “rest” state in this OnTimer event.

    timer events

    Don’t forget to change the attackCount back to 0 in the event Friendly attackCount >=3, if not then Timer will not trigger an OnTimer event. This is because the value of attackCount every loop will be equal or bigger than 3, and we will start the timer every loop, this will result in the timer unable to count to the time that we set and then the state value will never become empty. Lastly, don’t forget to change the event where our character attacks a little bit, so that the character will only attack when he is not in rest condition.

    Only attack while not rest

    Next I’m gonna add a simple AI to our enemy, for now the AI will only moves the monster closer when it see our character (it won’t attack for now). First add a line of sight behaviour to family Enemies, this behaviour will determine whether the character is close enough to the enemy or not. Then add an instance variable called radius to family Enemies, enemy will attack the character when  the character is in range of this radius, for beginning the radius value is 60 (in pixels), I have also changed the line of sight’s range to 150.

    Here, I write two new events. First is when the enemy sees that a character is near, second when it doesn’t see. When the enemy sees the character, it will move closer to its radius, when it doesn’t it will only stand still (for now, at least). This AI also change the enemy’s walking animation.

    simple enemy AI

    For now the enemy will only follow the character like a good dog, but later I want the enemy to be able to attack and use skills. And we’ll need a more complex AI for the boss, and the AI system will have to be easily customizable so that it will make our job easier when making another enemy. I will write about it on my next tutorial.

    ]]>
    Construct 2 RPG Series # 3: Implementing the Battle System https://gamedevacademy.org/construct-2-rpg-tutorial-part-3-implementing-the-battle-system/ Mon, 09 Sep 2013 12:32:11 +0000 https://gamedevacademy.org/?p=1241 Read more]]>
  • Construct 2 RPG Series by Aryadi Subagio (@AryadiPS):
  • After talking about battle design in the second part of my tutorial, I will implement what we have designed in the third part. Here, I’m starting to think of how to code the character stats, and how to use the weapons / equipments.  First I want to show you the screenshot of the final result of this part:

    Battle tutoria

    First, I’m going to add a few new families. Families are a Construct 2 feature that’s not available in the free version. I’m using a personal edition.
    new families
    The explanation of each family is as follows:

    • Enemies: Contains the list of enemies in this game
    • EnemySprites: graphical sprites of the enemy, has the same name as its enemy characters.
    • Friendly: Family of player character and other party members who participated in battle. Members of this family can’t be hurt by player’s character attacks, but can be healed or be a target of supportive magics.
    • FriendlyAttackFX: Special effect sprites of Friendly’s attacks, this will be tested for collision detection against the enemy
    • Weapons: List of all weapons in the game, the weapon doesn’t need to be equipped by the player character or other party members, this will be some kind of a database of weapons.

    I actually wanted to make a family of EnemyAttackFX but since the enemy still can’t attack the player, I think I will make it later. In every family there are instance variables that are different from each other, but useful for the family’s own purpose. This is an example of instance variables of Friendly family.
    Friendly instance variable
    The instance variables are the same that we have designed previously, but there are some changes. The weapon and armors instance variables are for us to know what weapon or equipment the player character is wearing right now.

    Let’s go on with the code. The first change is on the second event where we included the value of equipped weapons minAtk and maxAtk to the player. We do this so the attack FX knows how much added value from minAtk and maxAtk are included in the damage calculation. The next change is way down the events list, below the on charaAttacks() function, this is a bit long but actually it only writes what we have designed previously into code form. I maybe don’t need to explain this part because I wrote it in my previous post, but there are some things I want to explain.

    First, everytime I make a random number I always use floor(random(x)) where x is the value that I want + 1. I do this because the random function will generate a random number between 0 and 1 value below our desired number, and that’s why I added 1. The reason I use floor is to round the number down, because sometimes we get a value like 0.43672 or 12.38429 or something like that. That decimal value is not needed, so I round the number down.

    Second, I make a different thing between calculating physical damage and magical damage, but the hit possibility is still the same. This way I can experiment with various kinds of enemies and an attack that’s effective against it.

    Third, I added a text that shows damage dealt to the enemy, or if the attack missed. This is a visual feedback for the player. The capx file can be downloaded here: https://dl.dropboxusercontent.com/u/22420086/My%20RPG%20project.capx

    (NOTE: like before, the file may be different because my Indonesian blog post is already ahead of this one and I don’t really remember which part is edited.)

    You can now attack the monster and see how much damage you make. Some attack will hit and some will miss. The enemy stats are stats that I assume would be enough for an enemy of level 1 character, but you can experiment with your own values.

    I’ll see you on my next post.

    ]]>
    Construct 2 RPG Series # 2: Battle Design https://gamedevacademy.org/construct-2-rpg-series-2-battle-design/ Wed, 04 Sep 2013 18:13:02 +0000 https://gamedevacademy.org/?p=1201 Read more]]>
  • Construct 2 RPG Series by Aryadi Subagio (@AryadiPS):
  • Welcome to the second part of my Construct 2 RPG tutorial. In the last tutorial I said that I would make an enemy, but before that we needed to have a basic grasp of how the battle was gonna go, because that’s what the player’s interaction with the enemy is gonna be. So in this tutorial, I’ll be writing about battle design.

    Firstly we’ll look at stats. Stats are very common in RPGs, it’s the basics of characters and enemies/ Although stats in RPGs are pretty common, some RPGs have some specific stats that others don’t have, here I will write about stats that are common in RPGs

          • HP: Health Points, the maximum health of the character/enemy, if the health is healed, it may not exceed this points
          • currentHP: The character’s current health points, if this goes down to zero the character dies
          • SP: Spirit points, needed to use skills/magics, if SP is restored the value cannot exceed this points
          • currentSP: The character’s current SP, cannot be less than zero.
          • ATK: Attack power. Determines the power of physical attack
          • DEF: Defense power. Determines the power of physical defense.
          • ACC: Accuracy. Determines the accuracy of attacks, whether it’s physical or magical.
          • EVA: Evasion. Determines whether the character is able to evade enemy’s attacks.
          • INT: Intelligence. Determines magical attack power.
          • RES: Resistance. Determines magical defense power.
          • LUK: Luck. Determines various things, from critical attack to item drop rate , or something elsa.

    Monsters and player characters will have the same stats, only differs in the value. Monsters will more likely have more HP than characters to give more challenge, and most monsters won’t have skills to help them fight (except bosses).

    Next is weapon’s stats, because it’s very common in RPGs for weapon to . These stats will add to player’s stats to help them in battle. Here are the weapon’s stats:

          • minAtk: Weapon’s lowest attack
          • maxAtk: Weapon’s highest attack
          • StatsMod: Stats of player character that this weapon modifies. Not all weapons have this stat so this may empty.
          • Element: Weapon’s element, this may empty.

    minAtk and maxAtk are bonus attack values for the player character from the weapon, the bonus attack point will be between minAtk and maxAtk, so the final damage dealt will be varying just like the usual RPGs. StatsMod is a spesific bonus for one stats for the equipping character, not all weapons have this so this may empty. An example of  StatsMod is a weapon that has a spiritual property that might increases equipping character’s SP. And then  Element stats is the element of the weapon, this is clear. A weapon may have an element from the start, or added through crafting. This is not all of weapon’s stats, there are more like the description, icon, buying price, and selling price. But for now, I’ll only focus on what the weapon would do in a battle.

    Beside weapon’s stats, there is also armor’s stats. Armor stats are the same with weapon’s stats, but they don’t have minAtk and maxAtk, but minDef and maxDef. The function of these two stats are the same with Atk, but used in defending.

    Next, I’m gonna write up about the calculations done when players are attacking enemies. Generally, the calculations that happen are: hit probability –> critical probability –> damage count.

    Formula for hit probability is:
    attacker’s ACC * rand(6) – devender’s EVA * rand(6)

    if the result is more than or equal to zero,  it means it hits, other than that the attack misses. The rand(6) function means taking a random number between zero and six.

    Formula for critical probability: The game will simply randomly take a random number between 1 and 300, if the value is less than or equal to the character’s LUK, the attack is a critical attack, other than that it’s a normal attack.

    And then there’s a physical damage calculation:
    (attacker’s ATK + rand(minAtk, maxAtk)) – (defender’s DEF + rand(minDef, maxDef))

    if the result is less than or equal to zero, it will be converted to one, to make sure there’s at least a damage dealt. Both random functions take attack values of attacker’s equipped weapon and defender’s equipped armor.

    Magical damage calculation:
    (attacker’s INT + rand(minMag, maxMag)) – defender’s RES

    minMag and maxMag are the same as minAt and MaxAtk, but they are for magical attacks and are stored in each magics (not each weapons). Magical damage calculation is a little different than physical attack calculation because the defender’s RES is not added with any defenses. In exchange for that, magical calculations will use elemental weaknesses calculation, and armor that increases RES will have an elemental defense power that might reduce opponent’s magic attacks.

    Table of elements

    This is a list of elements and their relations to each other. For now, it is not complete but will be completed later. That 50% value between fire and water means that a fire elemental attack will only deal 50% damage to defender with water elemental property.

     

    Fire
    Water
    Wind
    Earth
    Thunder
    Light
     Darkness

    Fire
    50%
    Water
    200%
    Wind
    Earth
    Thunder
    Light
    Darkness

    This table is still incomplete and I might add more elements if I feel needed. Later in code, after calculating magical damage, we need to calculate the elements of magic attack and defender’s element before reducing defender’s currentHP.

    I can still go on to write about battle design, because there are still more I haven’t discussed, like limit breaks for example. But for now this will do. The first code for the battle system will be for next tutorial. See you!

    ]]>