Book Image

CryEngine Game Development Blueprints

Book Image

CryEngine Game Development Blueprints

Overview of this book

Table of Contents (22 chapters)
CRYENGINE Game Development Blueprints
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating an ammo class


Now that we have created our weapon system, it is time for us to create an ammunition system. Ammunition is what our weapons use to cause damage. It can be anything from a bullet to a magic spell, anything that results in damage caused by firing some weapon. Since we wish to achieve a modular and extensible design, we will accomplish this using interfaces once again.

Creating the IAmmo class

Since we need our game to support many ammunition types and we want to write clean, modular, OOP C++ code, it is essential that we create an ammo interface which we will call IAmmo. Let's do it:

  1. Create a new file called IAmmo.h that will hold our IAmmo interface declaration. It should look like this:

    #ifndef __IAMMO_HEADER__
    #define __IAMMO_HEADER__
    
    
    #include <CryString.h>
    #include <Cry_Math.h>
    
    
    
    /// <summary> The IAmmo Interface. Used To Represent Any Type Of Ammunition/Projectile. </summary>
    struct IAmmo
    {
      virtual ~IAmmo() {}
    
      //////////////////////...