top of page
CartoonMe.png
artstation_logo_icon_145479.png
InBug-Black.png
[WK 6-8] Implement, test and refine the traits system
Exploring the asset package

The asset supplies me with two scriptable objects:

Champion = Define a unit including it’s health / damage / assets for the unit / cost / attack range / traits (Figure One)

ChampionType = Define a trait including the effect bonus it gives / numb of units threshold 

The championType is a container that allows me to select from different kinds of trait bonus’. At the moment this currently consists of Damage / Stun / Heal / Defence.  

These champion bonus’ are part of their own class. The champion bonus is applied in one of two ways, either it’s applied when a unit attacks or it’s applied when a unit is hit. 

 

A couple of areas that this asset is different from TFT: 

  • The shop doesn’t restrict the appearance of champion so 4 cost champions will show up even if the player hasn’t upgraded the shop – this will affect the amount of traits that I can make unless I change this because it makes all units appear at the same frequency so you have a chance to never see certain units. TFT is set up so that each level changes the frequency of different costing units to appear. 

  • Another thing that’s different is that units in TFT have an ultimate ability that they build up to every auto attack (unless they have a special ultimate) whereas units in the asset only auto attack and their trait bonus is applied to their auto attack 

Changing the way trait bonus' are activated
1st iteration of checking bonus'.png
Version One

In the original script the bonus' were being activated based on a list that was stored in the AIOpponent class and the GameplayController class.

The disadvantage of this is that every unit from a team will have all active bonus' applied to it. This limits how unique any traits can be because they're applied across the whole team. [needs better explanation]

This would create significant balance issues for some traits. For example with Hound if the whole team was targeting the enemy with the lowest health then the enemy team would be defeated very quickly. This was partly because it limits the amount the enemy team can apply effects creating a significant disadvantage.

Version Two

My attempt at changing the way active bonus' are applied was to add a bool within the traits themselves and a reference within the character controller to their own trait bonus'. This means that each unit is only concerned about it's own traits as opposed to everyone's traits.

This created issues though because...

2nd iteration of checking bonus status.png
CheckIfBonusIsActive.png
changed the way bonus' are checked.png
Version Three

My final change created a more positive outcome. I created a method within the champion controller script that could be called every time a function needed to apply a bonus value. This method would run through the list of all active traits and compare it to that champions stored traits. If it found a match then the trait could be applied.

This way of doing it was much better because 

Bonus specific mechanics

I was able to use a lot of the pre existing functionality as a basic framework however I had to adapt some of the pre-exisintg functions i.e. ApplyOnAttack / ApplyOnHit and create new functions to make more specialised bonus behaviours including: OnTauntEnemies / OnGotBleed / OnHealAllies. According to my research for TFT players like the more niche traits with more specialised bonus because it adds variation to the game and different possibilities for strategies so this was an important spect to get right.

Then there were also some effects where I had to think about the math involved. I wanted to maintain the abstractness of the bonus class so I wasn't creating loads of different variables to apply effects in different ways so I had to think about how I could manipulate the bonusValue with different operations to achieve different effects.

For example with the Pastoral trait I needed the bonus value to represent both a percentage chance of the stun happening as well as a scaler for how much damage the champion should face when surrounded by other champs. 

ApplyOnAttackSnippet.png

For the percentage chance I can just divide by 100. Then for the scaler value I would multiply it by how many attackers were targeting this unit. Then I take that value from 100 and divided it by 100 to turn it into a percentage scaler. Finally I multiplied that value by the incoming damage to scale the incoming damage.

OnGotBleed.png
OnGotBleed

For the gun trait I had to create a function to be able to create a bleed effect.

Essentially how the bleed works is that it's called everytime units with the gun trait attack. At first this threw me off because I didn't know how to set the timer if it was going to be called every second. I realised I could use the same bool that applies the the bleeding or not to determine if the timer needed to be reset.

OnHealAllies / OnTauntEnemies

For the toy and the pastoral trait I needed a function, which allowed me to randomly select a unit from one of the teams. I copied a lot of the code from the pre-existing FindTarget functions to get the basics for finding a champion of a specific team. I then added all the champions from that team to a list.

I kept having an issue when it came to randomly selecting one of the champions from the list. It really confused me for at least a week but after I sorted out some of the other issues with the project mainly around how the trait bonus' were handled [as discussed above] I realised it was only hvaing an issue when there was just one member of the team. I had to add a condition on line 830 which checked if there was more than one champion on one team. This then stopped the error from happening.

onhealallies2.png
onhealallies1.png
OnHealAllies3.png
bottom of page