End-game K/D Ratio (🟧 4-5/10)

This is a tutorial on how to make a K/D Ratio that will show at the end of the game. For those who don’t know, a K/D Ratio is a statistic in popular shooting games that shows how many times you died versus how many times you knocked out another player.

This system is designed to increase UX (user experience), which will unfortunately create the following disclaimer:

NOTE! This design uses blocks, repeaters, and properties. I will try to explain them as best as I can throughout this guide, but if you have any other questions, please let me know and I’ll try to help.

Example

In this scenario, I knocked out a sentry twice and it knocked me out once. This is what the end-game screen looks like:

Note that yes, the system will recognize that a player knocked out a sentry as well, not only players. However, the leaderboard does not account for sentries as knockouts as I have 0 Knockouts on the leaderboard.

Tutorial

Here is the full system we will be building today:

There will be two parts to this tutorial. Part one will include creating the register system, while Part two will include the end-of-game widget and combination of the two values. Additionally, there is a third part that includes a simplified system that does not have Repeaters or Blocks, which will be much easier for those who are less-experienced with such devices.
If you’re able to build either, pick whichever suits your needs.

Part One - Register System

This is the register system:

The register system will keep track of how many players you have knocked out (kills) and how many times you have been knocked out (deaths).

Step 1: We will begin by placing a Lifecycle device. Set the Event to listen for when “Player Knocks Out”.

Step 1

Step 2: Add a Counter device with a default value of 0. Set “Yes” to Update Property and the Property to Update as “Kills”. Important: Set the Count Scope to “player” so that the Counter updates per player and not all players.

Step 2-A
Step 2-B
Step 2-C

Step 3: Connect a wire between the Lifecycle device and the Counter so when “Event Occurs” → “Increment counter”.

Step 4: Place a Property device and set the Name to “Kills”. Make sure the Type is a Number with a default of 0 and that it again updates per player in the Property Scope.

Step 5: This is one register complete. Select all three devices and copy them to a different location with the following changes made:

  • Reconnect the wire between the Lifecycle device and the Counter when “Event Occurs” → “Increment Counter”.
  • Change the Lifecycle device’s Event to “Player Knocked Out”.
  • Change the Property Name in both the Counter and the Property devices to “Deaths”.

No other changes should need to be made with the copied system. To test if the system works, temporarily show the Counters when the game starts. Place a Sentry and a Starting Inventory that gives you a weapon. What should happen is that when you knock out the Sentry then the first system’s Counter should go up, and when you are knocked out by the Sentry the second system’s Counter should increase. If something doesn’t work, make sure your property names are spelled correctly and that all other parts of the system are correct.

End Part 1

Part Two - Combination System

This is the combination system:

Combination System full

The combination system will take both the K and D values and regularly combine them into, literally, “K/D”, which will then be displayed at the end of the game.

Step 1: Begin by placing another Lifecycle device, setting its event to listen for “Game Start”.

Step 1

Step 2: Place a Repeater with a Task Interval of 1.0 seconds and a Stop Strategy to “After receiving on a channel”.

Step 2

Step 3: Connect a wire from the Lifecycle device to the Repeater so when “Event Occurs” → “Start repeater”.

Step 4: Place a Trigger. Set Visible In-Game and Trigger by Player Collision to No. Go into the Blocks section and create a new “When triggered…” block with the following code:

Step 5: Connect a wire from the Repeater to the Trigger so when “Repeater Runs Task” → “Trigger”.

Step 6: Place another Property device and set its Name to “KD Ratio”. Important: Make sure the Property Type is set to Text, not number. Leave the default value blank but ensure the Property Scope is per player once again.

Step 7: Place an End of Game Widget device reading the Property “KD Ratio”. Feel free to update the other settings as you please. Here’s an example of what it could look like:

End Part 2

Part Three - Simplified System

This simplified system will display both K and D similar to Part 2, except in two separate bubbles instead of one.
To make the simplified system, first, create the system from Part 1.

When that is complete, continue with the following:

Step 2: Place two End of Game Widgets. Set one to read the Property “Kills” and the other “Deaths”. Feel free to update the other settings as you please.

End Part 3

I hope that this tutorial helps with your endeavors in GKC. Good luck and have fun building!

11 Likes

Nice guide!

1 Like

Additional note: From my understanding, a regular KD that is not a fraction but instead a decimal like most FPS games is not possible with the limitations of Property devices. I am looking for a solution but for the time being a combined fraction will have to do.

2 Likes

You can do decimals. Just set it inside of the block. Great guide though!

I see, thanks. I’ll do some more testing. Glad you liked it!

1 Like

I don’t think that you need the loop. I think you can just calculate it when the channel that ends the game is broadcast, or when one of the properties is changed, if the first method doesn’t work.

Could you make it visible when you play the game?

Yes. Make the k/d property broadcast to an overlay block. The block should set the text to the k/d property.

1 Like

Nice guide overall!

You can get k/d decimals by simply dividing kills by deaths (very simple)

Right, but does having a decimal sent to a property force-round it to an integer?

This is kind of off topic, but how do you make that so when you click on text, it opens more of text like how you did?

Can you elaborate further on that?

Do you mean clicking on a Text device it opens a modal on screen?

Can you set the k/d ratio decimal to a property, and then set the leaderboard to it?

It rounds repeating decimals at the thousandth place unless the result is over the digit limit and should keep decimals unless the decimal number is above 17 digits.

No like on this post, where you have to press on “part one” and it opens the text after pressing on it.

Ohh yeah ok
When writing a draft click on the settings gear and select Hide Details

Screenshot 2023-10-30 09.54.09

To type it manually, write the following:

[details="Title"]
The text to hide
[/details]

Hope this helps

Thanks man, this gonna help alot.

1 Like

Community difficulty rating

  • 0/10
  • 1/10
  • 2/10
  • 3/10
  • 4/10
  • 5/10
  • 6/10
  • 7/10
  • 8/10
  • 9/10
  • 10/10
  • 11/10
0 voters