Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Building an RPG  with Unreal 4.x

You're reading from   Building an RPG with Unreal 4.x Get to grips with building the foundations of an RPG using Unreal Engine 4.x

Arrow left icon
Product type Paperback
Published in Jan 2016
Publisher
ISBN-13 9781782175636
Length 360 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Alan R. Stagner Alan R. Stagner
Author Profile Icon Alan R. Stagner
Alan R. Stagner
Steve Santello Steve Santello
Author Profile Icon Steve Santello
Steve Santello
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with RPG Design in Unreal FREE CHAPTER 2. Scripting and Data in Unreal 3. Exploration and Combat 4. Pause Menu Framework 5. Bridging Character Statistics 6. NPCs and Dialog 7. Gold, Items, and a Shop 8. Inventory Population and Item Use 9. Equipment 10. Leveling, Abilities, and Saving Progress Index

RPG design overview

With all that aside, we're going to take a look at the design for the RPG we will be developing over the course of this book, which we'll call Unreal RPG.

Setting

The game is set in an open field. Players will encounter enemies who will drop loot experience, which will increase the player's stats.

Exploration

While not in combat, players explore the world in an isometric view, similar to games such as Diablo. In this view, players can interact with NPCs and props in the world, and also pause the game to manage their party members, inventory, and equipment.

Dialogue

When interacting with NPCs and props, dialogue may be triggered. Dialogue in the game is primarily text-based. Dialogue boxes may be either linear, the player simply presses a button to advance to the next dialogue page, or multiple-choice. In the case of multiple-choice, the player is presented with a list of options. Each option will then proceed to a different page of dialogue. For instance, an NPC might ask the player a question and allow the player to respond "Yes" or "No", with different responses to each.

Shopping

A shop UI can also be triggered from a dialogue. For example, a shopkeeper might ask the player whether they want to buy items. If the player chooses "Yes", a shop UI is displayed.

While in a shop, players can buy items from the NPC.

Gold

Gold can be attained by defeating monsters in battle. This gold is known as a type of enemy drop.

The pause screen

While the game is paused, players can do the following:

  • View a list of party members and their statuses (health, magic, level, effects, and so on)
  • View abilities that each party member has learned
  • View the amount of gold currently carried
  • Browse an inventory and use items (such as potions, ethers, and so on) on their party members
  • Manage items equipped to each party member (such as weapons, armor, and so on)

Party members

The player has a list of party members. These are all the characters currently on the player's team. For instance, the player may meet a character in a tower who joins their party to aid in combat. Note that in this book, we will only be creating a single party member, but this will lay the foundations of creating additional party members in your future developments.

Equipment

Each character in the player's party has the following equipment slots:

  • Armor: A character's armor generally increases defense
  • Weapon: A character's weapon generally provides a boost to their attack power (as given in the attack formula in the Combat section of this chapter)

Classes

Player characters have different classes. A character's class defines the following elements:

  • The experience curve for leveling up
  • How their stats increase as they level up
  • Which abilities they learn as they level up

The game will feature one player character and class. However, based on this player character, we can easily implement more characters and classes, such as a healer or black mage, into the game.

Soldier

The Soldier class focuses on increasing attack, max HP, and luck. Additionally, special abilities revolve around dealing with lots of damage to enemies.

Therefore, as the Soldier class levels up, they deal more damage to enemies, withstand more hits, and also deliver more critical blows.

Combat

While exploring the game world, random encounters may be triggered. Additionally, combat encounters can also be triggered from cut scenes and story events.

When an encounter is triggered, the view transitions away from the game world (the field) to an area specifically for combat (the battle area), an arena of sorts.

Combatants are divided into two teams: the enemy team and the player team (consisting of the player's party members).

Each team is lined up, facing each other from the opposite ends of the battle area.

Combatants take turns, with the player team going first, followed by the enemy team. A single round of combat is divided into two phases: decision and action.

Firstly, all combatants choose their action. They can either attack an enemy target or cast an ability.

After all combatants have decided, each combatant executes their action in turn. Most actions have a specific target. If, by the time the combatant executes their action, this target is not available, the combatant will pick the next available target if possible, or else the action will simply fail and the combatant will do nothing.

This cycle continues until either all enemies or players are dead. If all enemies are dead, the player's party members are awarded with XP, and loot may also be gained from the defeated enemies (usually, a random amount of gold).

However, if all players have died, then it is game over.

Combat stats

Every combatant has the following stats:

  • Health points: A character's health points (HP) represents how much damage the character can take. When HP reaches zero, the character dies.

    HP can be replenished via items or spells, as long as the character is still alive. However, once a character is dead, HP cannot be replenished—the character must first be revived via a special item or spell.

  • Max health: This is the maximum amount of HP a character can have at any given time. Healing items and spells only work up to this limit, never beyond. Max health may increase as the character levels up, and can also be temporarily increased by equipping certain items.
  • Magic points: A character's magic points (MP) represents how much magic power they have. Abilities consume some amount of MP, and if the player does not have enough MP for the ability, then that ability cannot be performed. MP can be replenished via items.

    It should be noted that enemies have effectively infinite MP, as their abilities do not cost them any MP.

  • Max magic: This is the maximum amount of MP a character can have at any given time. Replenishing items only work up to this limit, never beyond. Max magic may increase as the character levels up, and can also be temporarily increased by equipping certain items.
  • Attack power: A character's attack power represents how much damage they can do when they attack an enemy. Weapons have a separate attack power that is added to regular attacks. The exact formula used to deal with damage is as follows:

    max (player.ATK – enemy.DEF, 0) + player.weapon.ATK

    So firstly, enemy defense is subtracted from the player's attack power. If this value is less than zero, it is changed to zero. Then, the weapon's attack power is added to the result.

  • Defense: A character's defense reduces the damage they take from an enemy attack.

    The exact formula is as given just previously (defense is subtracted from the enemy's base attack value and then the enemy's weapon attack power is added).

  • Luck: A character's luck affects that character's chance of landing a critical hit, which will double the damage dealt to an enemy.

    Luck represents the percent chance of dealing with a critical hit. Luck ranges from 0 to 100, representing the range from 0% to 25%, so the formula is as follows:

    isCriticalHit = random( 0, 100 ) <= ( player.Luck * 0.25 )

    So, if the player's luck is 10, given that the random number falls at the number 10 within its range of 0 to 100, then the chance of dealing a critical hit is 2.5%.

    The critical hit multiplier is applied after the damage is calculated, as follows:

    2 * (max( player.ATK – enemy.DEF, 0 ) + player.weapon.ATK )

Combat actions

Actions during combat are divided into three categories: attack and ability.

Attack

Every character has an attack ability that costs zero MP and, for player characters, is shown as the first option in the action menu during the decision phase of a round.

Generally, an attack takes a single enemy target and deals damage to that enemy. The damage formula is as given previously for the attack power stat.

Ability

Every character, as mentioned earlier, has a set of abilities they know. Excluding attack, abilities cost some amount of MP and have a variety of effects. Abilities can have different types of targets, as follows:

  • A single enemy
  • All enemies
  • A single ally
  • All allies

Abilities can heal targets, revive dead targets, remove some effects, summon temporary allies, temporarily increase a character's stats, and more. However, abilities never restore MP.

Abilities have a set MP cost. This is the amount of MP the character must have in order to perform that ability, and the amount of MP that will be consumed upon casting the ability.

After combat/victory

Once all enemy combatants have died, the player wins the fight. Upon winning the fight, the player is rewarded with random loot, and experience points are divided between party members.

Loot

Every enemy defines the loot that is received upon defeating the enemy. This includes how much gold is received to defeat this enemy.

Experience

Each enemy defines how much experience it is worth. After combat, the experience of every defeated enemy is summed up. Then, this value is evenly divided between all currently living players (any party member who has died does not receive any EXP) and rounded up to the nearest integer (for example, if the total experience is 100 and there are three party members, then 100/3 = 33.3333, which is rounded up to 34).

Experience and leveling

As party members earn experience, they will level up.

The amount of experience required to go from one level to the next is given by the following formula:

f(x) = (xa) + c

Here, x is the current level, a is a positive value greater than one (affecting how steeply the curve increases), and c is the base offset, which is the amount of experience required to go from level 1 to level 2. This defines a simple exponential value increase. The a and c values are defined by the character's class.

To get the total amount of experience required to level up from the current level, the preceding formula is calculated and summed for each level up to the current level. For instance, if we want to know how much total EXP is required to get to level 31 (from level 30), we calculate it in the following way:

f(1) + f(2) + f(3) + … + f(30)

When a player levels up, their stats increase and they may also learn a new ability. Stat increases and learned abilities are defined on the character class.

The maximum level of any character in the game is 50.

Stat increases

For a given character class, for every character stat, the class defines a starting value at level 1 and an ending value at 50. For example, using standard math library functions, the value of attack for any given level would be a simple linear interpolation between the starting value and the ending value, using the character's level (divided by max level) as the interpolation value (the result would then be rounded up to ensure it is a whole integer number).

So, for example, if a soldier's max HP starts at 100 at level 1 and ends at 1,000 at level 50, then at level 25 the soldier's max HP will be 550.

Learning abilities

Each character class defines a table of abilities. Each entry in the table references which ability will be learned and at what level that ability is learned. When the character levels up, any abilities in the table that has the given level will be added to that character's known abilities.

Any abilities learned at level 1 are automatically added to a character's skill set.

Game over

If all players have died, either during combat or in the field, then the game ends.

You have been reading a chapter from
Building an RPG with Unreal 4.x
Published in: Jan 2016
Publisher:
ISBN-13: 9781782175636
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime