Work Samples
Resume
About Me
Email Me!

Portfolio | Stefan Andersson

Work Samples
Resume
About Me
Email Me!
 We had a system in place that I had developed earlier called DamageContext, which would allow us to glean information about a damage event:  A weapon has an attached DamageContext component and things the DamageContext needs to be aware of:  Collide

We had a system in place that I had developed earlier called DamageContext, which would allow us to glean information about a damage event:

A weapon has an attached DamageContext component and things the DamageContext needs to be aware of:

Colliders (even a regular collider, like the handle, can cause impact damage)

Damage-causing components (like Piercing, used for arrowheads)

When a body part impacts a collider, we check if the collider is associated with a DamageContext

The body part may also receive damage events from components like Piercing, and these carry a refernce to the DamageContext

The body part can then retrieve information from DamageContext like, “is the weapon this is attached to held by anyone, or was it recently held by anyone?”

The weapon itself can also listen to its DamageContext to receive information about the damage events it was involved in, like “did I manage to kill anyone?”

 My starting point was here then, creating a script that could listen to OnKill events and use DamageContext to figure out if the player was holding the weapon. Except, when I tested it the accuracy was terrible - unusable, even! It turned out that w

My starting point was here then, creating a script that could listen to OnKill events and use DamageContext to figure out if the player was holding the weapon. Except, when I tested it the accuracy was terrible - unusable, even! It turned out that when the player strikes an enemy, it’s often just as likely that what actually kills them is the enemy hitting their head against the wall, poking themselves with their own sword, falling off a platform or suffering any of a myriad of other horrible fates. The solution then was actually quite simple - like the adage goes; “keep it simple, stupid!”

Instead of somehow trying to figure out if the player was technically responsible, simply try to figure out if the player is likely to believe they were responsible! Instead of telling DamageContext it scored a kill when it technically did, I created a system called DeathBlameHandler that kept a history of recent damage events; when an enemy dies, the system goes through the history to check if any of the recent events were associated with the player, and if so, uses that as the death-causing event and calls that DamageContext! This worked great, as you can see in the video! When I kill someone using a new weapon, a new box is ticked on the wall, but when I re-use a weapon, it does not.

There are times when it feels a bit too generous, but I would rather the player feel they were treated unfairly in the positive sense than the negative.

1 2
Previous Next
 We had a system in place that I had developed earlier called DamageContext, which would allow us to glean information about a damage event:  A weapon has an attached DamageContext component and things the DamageContext needs to be aware of:  Collide
 My starting point was here then, creating a script that could listen to OnKill events and use DamageContext to figure out if the player was holding the weapon. Except, when I tested it the accuracy was terrible - unusable, even! It turned out that w
Back to Top
stf.andersson@gmail.com