Book Image

Building an RPG with Unreal 4.x

By : Steve Santello
Book Image

Building an RPG with Unreal 4.x

By: Steve Santello

Overview of this book

Now that Unreal Engine 4 has become one of the most cutting edge game engines in the world, developers are looking for the best ways of creating games of any genre in the engine. This book will lay out the foundation of creating a turn-based RPG in Unreal Engine 4.12. The book starts by walking you through creating a turn-based battle system that can hold commands for party members and enemies. You’ll get your hands dirty by creating NPCs such as shop owners, and important mechanics, that make up every RPG such as a currency system, inventory, dialogue, and character statistics. Although this book specifically focuses on the creation of a turn-based RPG, there are a variety of topics that can be utilized when creating many other types of genres. By the end of the book, you will be able to build upon core RPG framework elements to create your own game experience.
Table of Contents (17 chapters)
Building an RPG with Unreal 4.x
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Applying the correct damage in combat


In battle, you will notice that the enemy and the player both do 10 points of damage no matter what. The current attack power and defense do not seem to be calculated. This is because, in Chapter 3, Exploration and Combat, when we created the combat actions, we hardcoded the damage to be target->HP -= 10, which means that no matter who is attacking, they will deal 10 points of damage to the player. We can easily fix this to use the actual stats of enemies and players by navigating to Source | RPG | Combat | Actions and opening TestCombatAction.cpp. Find target->HP -= 10; and replace it with target->HP -= (character->ATK - target->DEF) >= 0 ? (character->ATK - target->DEF):0;.

This is a ternary operator. When a target is attacked, whether it is a party member or an enemy, the target's HP will go down by the attacker's attack power minus the target's defense power only if this result ends up being the same or greater than 0. If the...