Passive Abilities
Starting Date: 01/03/2025
Ending Date: 15/04/2025
This blog is about creating passive abilities for all of the characters which all have unique behaviours in the game and can occur at random points in the game.
Objective
The goal of this blog is to create each character's passive ability and to be activated at the right time, this will involve identifying how the ability should be implemented and when is the suitable time for that ability to activate.
​
The first objective is to get double wielder's passive aggression functioning which applies suitable thrust and guard to be halved and doubled depending on the current stance with aggressive doubling thrust but halving guard and passive doubling guard but halving thrust, this will involve the character to decrease the stance cooldown at the start of the turn which when it turns to 0 then the stance will swap to the other stance that it is not currently on. This will also involve the character to apply suitable thrust and guard to be halves and doubled depending on the current stance they're on during combat..
​
The second objective is to get grim reaper's soul steal functioning which heals the grim reaper by 25% of the damage dealt (rounding down) in combat, this will involve calculating the damage and converting the float value to a integer once combat is complete.
​
The third objective is to get lucky gambler's luck be this lady tonight functioning which randomly changes the mana the player gains at the start of the turn ranging between 1 to 30 which will gain the player coins equal to the random mana value, this will involve randomly choosing a number at the start of the turn and gain coins equal to the that chosen number.
​
The final objective is to get robotic superstar's dirty deeds functioning which will deal damage back to the opponent equal to the damage received as long as the damage taken was 20 or above, this will involve checking the damage during combat in order for dirty deeds to identify the amount of damage taken to then deal back to the attacker.
Techniques
Observer Pattern
The observer pattern is a design pattern that provides a one to many dependency with one event subject invoking all the observer methods that are listening to the subject, this provides one event to call multiple methods in different classes.
​
I used observer patterns for all four passive abilities which will have the passive ability listen to a certain event is either the player states or the combat system to then call out the method to activate the ability at the correct moment.
​
Using observer patterns were very beneficial for me as I can create passive abilities towards having the ability method to call one of the existing subjects to play once the event subject has been invoked, which leads the player to be able to have each ability activate at specific moments in the game.
Random Range
Random range is a unity engine method that can select a random range between the minimum and maximum value, with floats they include the maximum float value whilst integers exclude the maximum value.
​
I used random range towards the lucky gambler's passive ability which will provide a random int range between 1 to 31 to randomly select a number for that number to become the current mana that the player can use on their turn.
​
This was an effective method for players who are playing with the lucky gambler because the player could get small or high amount of mana which provides action towards the outcome of the ability whether they can decide to go all in or act careful on what they choose, leading the player to act responsible towards using certain cards with the amount of mana they obtained.
Enumeration
Enumerations are constants that provide a list of types that can classify a type in a script to execute certain coding depending on the value of the enum type. Enums also have numerical values meaning that they can be used towards certain equations or conditional statements.
​
I used enums towards the double wielder's passive ability which will identify the stance the character is currently on which will either double or half thrust and guard.
​
This was an effective constant to identify the player's current stance because the player will identify whether to play risk on playing aggressive by attacking the player or play safe on playing passive to reduce the amount of damage taken, leading the player to change their playstyle depending on the stance currently on.
Challenges
Dirty Deeds - Hitting Himself when Attacking
The only issue I had with the passive abilities was with robotic superstar's passive ability where if the character is attacking and deals 20+ damage, the character will deal damage to himself, this shouldn't happen because the passive ability should only occur when the character is defending.
​
This is an issue because the player will deal damage to themselves if they deal more than 20 damage with robotic superstar, causing the player to deal less damage than other players to prevent dealing damage to themselves.
​
This was fixed by encapsulating the state manager to get the current state, this means that the ability checks if the player's current state is the defend state to identify that the player is defending and took 20+ damage then they will deal damage to their opponent, leading the player to deal as much damage as they can when attacking without any consequences.
Achieved
Passive Aggression Complete
Passive aggression has been complete by using an observer pattern to call one ability method at the start of the turn to decrease the stance cooldown and change the stance type once the cooldown reaches to zero along with applying the change in multipliers depending on the stance and the combat state, as well as call the other ability method before combat that will check the current combat state and the stance to double/half thrust/guard.
​
This was efficient for the player to have a risk and reward character in the game because double wielder can either deal high damage but also receives high damage or deal low damage but received low damage as well. This leads the player to consider the unique playstyles to occur when in a certain stance as well as the certain situation they're in.
Soul Steal Complete
Soul Steal has been complete by using an observer pattern to call during combat to heal themselves which converts the float value into an integer value in order for the value to heal the player's current health.
​
This was a unique behaviour that can allow the player to heal themselves which can be an interesting mechanic for the player because if they're low on health they can aim to do high amount in order to heal themselves during combat. This leads the player to have an advantage to heal themselves in the most unique way.
Luck in this Lady Tonight Complete
Luck in this lady tonight has been complete by using an observer pattern to call at the start of the turn which will regain mana randomly between 1 to 30 for the player to use on the cards.
​
This provides the play to either act cautious on their decision making or go all in without any consequences, this is because of the pre action outcome that occurred to the player to decide what actions they can provide and what can be suitable for them to use. This can lead the player to high and low risk on playing this character depending on the chance that occurs from the ability.​​
Dirty Deeds Complete
Dirty Deeds has been complete by using the observer pattern to call during combat which the ability method will check the encapsulated value of the current state in the state manager if they're currently in the defend state and the damage (attack value - defend value) was equal or higher than 20 will deal damage to the opponent equal to the damage taken.
​
This provides a confidence on the player using robotic superstar and a risk on the opponent because the player can benefit taking high amount of damage in order to counter back damage to the opponent, whereas the opponent will need to be aware on the damage they dealing to prevent receiving damage equal to the damage dealt to the player. This leads the player to weigh in the damage taken to return the damage back to the opponent.​
Conclusion
Overall, I have learnt that using the observer pattern is a very useful pattern for passive abilities in general in the game due to calling each abilities at specific moments as well as certain techniques such as random range and enumerations can benefit specific abilities that can provide unique behaviour for an ability in the game.
​
As a programmer, I have learnt that using observer patterns can make methods more cleaner and straightforward to call from rather than providing conditional statements and referencing the scripts and then adding the method. I have also learnt that random range is a crucial tool when adding randomness in the game by having the method providing a random number every time and finally I have also learnt that providing a enum type can be used for conditional statements to identify to provide unique behaviour in the method.
​
I feel like the observer pattern and enumerations will be commonly used in most games with observer calling multiple methods and enumerations identifying the type in a script. As for random range it'll depend on how much luck elements are included, for instance a game like this will often allow me to use random range more frequently whereas a puzzle game might not allow me to use the method often.