Introduction to Combat Systems and Loot

Get a brief introduction to what we’ll learn in this chapter.

We'll cover the following

Writing spawn functions for every item, monster, or other entity we imagine can take time, and waiting for our game to recompile so that we can test those new ideas isn’t fun. But don’t worry, there’s something that can help: data-driven design.

With data-driven design, instead of hard-coding entities into our game’s source code, we specify these entities in a data file, which is read when the game generates a new level. This type of setup lets us rapidly test new ideas.

Terminology

A data-driven design loads as much data as possible from data files and uses it to populate the game entities. This is really useful if we’re working with a team of designers and developers because team members can change the game without having to learn Rust.

An ECS is data-oriented because it focuses on storing data in memory and providing efficient access to it.

What will we learn?

In this chapter, we’ll move our spawning functionality into a generic function that will read our entity definitions from a file and create components using that data. We’ll also add varying damage levels to monsters and weapons, and we’ll extend the combat system to use the new values, improving variety in our game with more tactical choices for the player to make.

Get hands-on with 1200+ tech skills courses.