Why I reverted back to Unreal's native damage framework in Tower Defense Starter Kit

I've been using a custom Damage Interface to handle all damage events in the Tower Defense Starter Kit. This interface was added a few years ago to enable for support additional parameters like Critical hit damage and Critical chance to be passed on as part of the damage application process. But in the latest v2.22 update for Tower Defense Starter Kit, I finally reverted back to the Unreal Engine's inbuilt damage system.

The primary reason for this change was driven by the fact that Unreal's native damage framework provides us with an easy and straightforward solution to use Event Dispatchers for listening to and responding to damage events.

While it is definitely possible to add in new damage event dispatchers to the toolkit, it comes with the drawback of requiring both the Tower and Wave AI classes to have their own unique event dispatchers. Which means, any object that wants to be registered as an observer will first need to do a cast operation to access the dispatcher. If on the other hand, we were to use Unreal's native damage framework, there would be no need to add new dispatchers for each parent class nor would the cast operation be required in order to access the event dispatcher.

So I started looking for ways to incorporate the critical hit data as well as any other future requirements like say elemental damage types into Unreal's native damage model. I figured that critical hits could be handled in one of two ways: either create a new actor component to handle all damage related calculations including critical hits, or create a global function in a blueprint function library to calculate critical damage. Since I was not keen on having an additional component in every single Wave AI and Tower actor just for this purpose, I decided to go ahead with the later option. So now I just call the aforementioned global function to calculate the critical hit damage first before passing it on to the Apply Damage function as shown below:

As mentioned earlier, I want this to be scalable with my future plans for Tower Defense Starter Kit, including the idea of introducing Elemental Damage Types to the toolkit. After giving it some thought, I believe that it can be easily achieved through the use of Unreal's Damage Type classes, which can be passed through the Apply Damage function. So I'm really hoping to get around to fleshing out the damage framework once I wrap up work on the Hero system.

Comments