Skip to content

Instantly share code, notes, and snippets.

@zuloo
Last active January 8, 2022 18:40
Show Gist options
  • Save zuloo/84bbace7ea850ec84de60b4d9ea975bb to your computer and use it in GitHub Desktop.
Save zuloo/84bbace7ea850ec84de60b4d9ea975bb to your computer and use it in GitHub Desktop.
Function to generate the funfact at round end from a CS:GO demofiles cs_win_panel_round event
export function FunFactOry(token:string, s1:string, s2:number, s3:number):string {
switch (token) {
case "#funfact_ace":
return `Ace! ${s1} killed the entire enemy team.`;
case "#funfact_best_accuracy":
if (s3) {
return `${s1} had an accuracy of ${s3}%.`;
}
return `${s1} had the best accuracy with ${s2}%.`;
case "#funfact_best_counterterrorist_accuracy":
if (s3) {
return `${s1} had an accuracy of ${s2}%, while their team's was ${s3}%.`;
}
return `Counter-Terrorists had the best team accuracy with ${s2}%.`;
case "#funfact_best_terrorist_accuracy":
if (s3) {
return `${s1} had an accuracy of ${s2}%, while their team's was ${s3}%.`;
}
return `Terrorists had the best team accuracy with ${s2}%.`;
case "#funfact_blind_kills":
if (s2 > 1) {
return `${s1} killed ${s2} enemies while flashbanged.`;
}
return `${s1} killed an enemy while flashbanged.`;
case "#funfact_blind_kills_singular":
return `${s1} killed an enemy while flashbanged.`;
case "#funfact_bomb_carriers":
return `${s1} killed ${s2} separate bomb carriers in the last round.`;
case "#funfact_bomb_planted_before_kill":
return `No players were killed prior to the bomb being planted.`;
case "#funfact_bots_assumed":
return `${s1} assumed control of ${s2} bots that round`;
case "#funfact_broke_windows":
return `${s1} shattered ${s2} windows.`;
case "#funfact_ct_accuracy":
if (s3) {
return `${s1} had an accuracy of ${s2}%, while their team's was ${s3}%.`;
}
return `Counter-Terrorists had the best team accuracy with ${s2}%.`;
case "#funfact_ct_win_no_casualties":
return `Counter-Terrorists won without taking any casualties.`;
case "#funfact_ct_win_no_kills":
return `Counter-Terrorists won without killing any Terrorists.`;
case "#funfact_ct_win_time":
return `The CT team eliminated the T team in ${s2} seconds.`;
case "#funfact_damage_multiple_enemies":
return `${s1} did damage to ${s2} enemies.`;
case "#funfact_damage_no_kills":
return `${s1} had no kills, but did ${s2} damage.`;
case "#funfact_damage_with_grenade":
return `${s1} did ${s2} total damage with grenades`;
case "#funfact_default_weapon":
return `${s1} won the round without picking up any weapons.`;
case "#funfact_defended_bomb":
return `${s1} defended the planted bomb against ${s2} enemies.`;
case "#funfact_defuse_was_close_call_hundredths":
return `${s1} defused the bomb with 0.0${s2} seconds remaining.`;
case "#funfact_defuse_was_close_call_tenths":
return `${s1} defused the bomb with 0.${s2} seconds remaining.`;
case "#funfact_defuse_was_close_call_thousandths":
return `${s1} defused the bomb with 0.00${s2} seconds remaining.`;
case "#funfact_defused_with_dropped_kit":
return `${s1} defused the bomb with a dropped defuse kit.`;
case "#funfact_died_from_multiple_attackers":
return `${s1} took damage from ${s2} enemies before dying.`;
case "#funfact_domination":
return `${s1} dominated the most players.`;
case "#funfact_donated_weapons":
return `${s1} donated ${s2} weapons that round.`;
case "#funfact_empty_guns":
return `${s1} ran out of ammo using ${s2} guns.`;
case "#funfact_fall_damage":
return `${s1} took ${s2} damage... from the earth.`;
case "#funfact_first_blood":
return `${s1} drew first blood ${s2} seconds into the round.`;
case "#funfact_first_kill":
return `${s2} seconds into the round, ${s1} got the first kill.`;
case "#funfact_grenades_thrown":
return `${s1} threw ${s2} grenades that round.`;
case "#funfact_items_dropped_value":
return `${s1} threw away $${s2} worth of supplies.`;
case "#funfact_items_purchased":
return `${s1} bought ${s2} items.`;
case "#funfact_kill_defuser":
return `${s1} successfully stopped the bomb defuser.`;
case "#funfact_kill_rescuer":
return `${s1} killed the hostage extractor.`;
case "#funfact_kill_wounded_enemies":
return `${s1} finished off ${s2} wounded enemies.`;
case "#funfact_killed_before_dying":
return `${s1} killed ${s2} players before dying.`;
case "#funfact_killed_enemies":
return `${s1} killed ${s2} opponents.`;
case "#funfact_killed_half_of_enemies":
return `${s1} killed ${s2}% of the enemy team.`;
case "#funfact_kills_grenades":
return `${s1} killed ${s2} enemies with grenades.`;
case "#funfact_kills_headshots":
return `${s1} killed ${s2} enemies with headshots that round.`;
case "#funfact_kills_with_last_round":
if (s2 > 1) {
return `On ${s2} occasions with only one bullet left, ${s1} killed an enemy.`;
}
return `${s1} killed an enemy with their last bullet.`;
case "#funfact_kills_with_last_round_singular":
return `${s1} killed an enemy with their last bullet.`;
case "#funfact_kills_with_single_grenade":
return `${s1} hit ${s2} enemies with one grenade.`;
case "#funfact_kills_with_stattrak_weapon":
return `${s1} added ${s2} kills to their StatTrak™ weapons that round.`;
case "#funfact_knife_bomb_planter":
return `${s1} won on knife Level by killing the bomb planter.`;
case "#funfact_knife_in_gunfight":
return `${s1} brought a knife to a gunfight.`;
case "#funfact_knife_kills":
if (s2 > 1) {
return `${s1} had ${s2} knife kills this round.`;
}
return `${s1} killed an enemy with the knife.`;
case "#funfact_knife_kills_singular":
return `${s1} killed an enemy with the knife.`;
case "#funfact_knife_level_reached":
return `${s1} players reached gold knife level.`;
case "#funfact_knife_without_ammo":
return `${s1} got ${s2} knife kills after running out of ammo.`;
case "#funfact_molotov_burns":
return `${s1} torched ${s2} players with fire.`;
case "#funfact_money_spent":
return `${s1} spent $${s2} that round.`;
case "#funfact_num_times_jumped":
return `${s1} jumped ${s2} times during the round.`;
case "#funfact_number_of_overkills":
return `${s1} killed ${s2} players they were already dominating.`;
case "#funfact_pickup_bomb":
return `${s1} planted bomb after being owned by ${s2} teammates.`;
case "#funfact_posthumous_kills_with_grenade":
if (s2 > 1) {
return `${s1} got ${s2} grenade kills while dead.`;
}
return `${s1} killed an enemy with a grenade after dying.`;
case "#funfact_posthumous_kills_with_grenade_singular":
return `${s1} killed an enemy with a grenade after dying.`;
case "#funfact_quarter_health":
return `${s1} killed ${s2} players while under 25 health.`;
case "#funfact_respawned":
return `${s1} respawned ${s2} times during the match.`;
case "#funfact_revenge":
return `${s1} got revenge on ${s2} player${s2 > 1 ? "s" : ""}.`;
case "#funfact_revenge_singular":
return `${s1} got revenge on 1 player.`;
case "#funfact_rounds_without_dying":
return `${s1} lasted ${s2} consecutive rounds without dying.`;
case "#funfact_short_round":
return `That round took only ${s2} seconds!`;
case "#funfact_pulled_trigger":
return `${s1} pulled the trigger ${s2} times that match.`;
case "#funfact_shots_fired":
return `${s2} shots were fired that round.`;
case "#funfact_steps_taken":
return `${s1} ran ${s2} steps during the match.`;
case "#funfact_survival_time":
return `${s1} survived the longest: ${s2} seconds.`;
case "#funfact_survived_multiple_attackers":
return `${s1} survived attacks from ${s2} different enemies.`;
case "#funfact_t_win_no_casualties":
return `Terrorists won without taking any casualties.`;
case "#funfact_t_win_no_kills":
return `Terrorists won without killing any Counter-Terrorists.`;
case "#funfact_taser_kill":
return `${s1} tased ${s2} player${s2 > 1 ? "s" : ""}.`;
case "#funfact_taser_kill_singular":
return `${s1} tased 1 player.`;
case "#funfact_ter_win_time":
return `The Terrorist team eliminated the CT team in ${s2} seconds.`;
case "#funfact_terrorist_accuracy":
if (s3) {
return `${s1} had an accuracy of ${s2}%, while their team's was ${s3}%.`;
}
return `Terrorists had the best team accuracy with ${s2}%.`;
case "#funfact_ticking_time":
return `Terrorists won despite ${s2} CTs trying to defuse the bomb.`;
case "#funfact_used_all_ammo":
return `${s1} went completely dry on ammo.`;
case "#funfact_used_multiple_weapons":
return `${s1} used ${s2} different firearms.`;
case "#funfact_won_as_last_member":
return `As the last member alive, ${s1} killed ${s2} enemies and won.`;
default:
console.log(`unknown funfact_token: ${token}`);
if (Math.random() > 0.5) {
return `The cake is a lie.`;
}
return `Yawn.`;
}
}
//--- USAGE ---//
// uses demofile npm package
const demo = new window.demofile.DemoFile();
demo.gameEvents.on('cs_win_panel_round', (ev:any) => {
const user = demo.entities.entities.get(ev.funfact_player);
const name = user ? user.name : "unknown player";
console.log(FunFactOry(ev.funfact_token, name, ev.funfact_data1, ev.funfact_data2))
});
demo.parse( ... );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment