[Multiplayer] Programming Player Assists logic, need help!

I’m making a multiplayer team death match game. So far I got kills and death counts programmed. That part was easy. I’m using the TakeDamage function and doing the logic through the EventInstigator. The kills, deaths, and assist variables are in my PlayerState class and I update them through that. How would I do assists though? If any players does any damage on an enemy player and they die later on, then all those players that damaged him should get an assist count of +1. Where would I do that? I don’t think it makes sense to do it in TakeDamage.

Hey there, i would say that on TakeDamage if it’s not a kill shot you store the hit causer on a TMap where the float is the last time that character hit you. Then maybe on tick you check if x amount of seconds has passed (to time an assist is considered valid), if it has passed that value remove it from the list. A cleaner way of doing this is just storing a TArray and everytime you get hit you schedule/reschedule a timer with the max assist duration to call a function that takes a AEnemyCharacter as a parameter to take it out of the array. Once a kill happens you check all of the AEnemyCharacter you have in the array and attribute an assist to each one.

For each combatant, you keep a history of hits (a struct with relevant info). Then on death, go through the list and allot the credit to those who did the hitting.

I suppose you’d also want to clear it out if the game mechanics are such that early hits aren’t counted in a later death. You’d either clear them all out on some event (like when health regens), or keep a running queue and pull out old hits once they expire. And/or only keep the last X number of hits, or only keep the X highest-damaging hits – or however you want.

Thx, you’re second method was what I needed. It was simple and just what I needed

Good to know :slight_smile: