-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
var {parseTicks, parseEvent} = require('@laihoe/demoparser2'); | ||
|
||
const pathToDemo = "path/to/demo.dem"; | ||
// 1vX | ||
const X = 4; | ||
|
||
|
||
function find_if_1vx(deaths, round_idx, round_ends, tickData, X){ | ||
for (let i = 0; i < deaths.length; i++){ | ||
if (deaths[i].total_rounds_played == round_idx){ | ||
|
||
let tickData_slice = tickData.filter(t => t.tick == deaths[i].tick) | ||
let ctAlive = tickData_slice.filter(t => t.team_name == "CT" && t.is_alive == true) | ||
let tAlive = tickData_slice.filter(t => t.team_name == "TERRORIST" && t.is_alive == true) | ||
// 3 = CT | ||
if (ctAlive.length == 1 && tAlive.length == X && round_ends[round_idx].winner == 3){ | ||
return ctAlive[0].name | ||
} | ||
// 2 = T | ||
if (tAlive.length == 1 && ctAlive.length == X && round_ends[round_idx].winner == 2){ | ||
return tAlive[0].name | ||
} | ||
} | ||
} | ||
} | ||
|
||
let deaths = parseEvent(pathToDemo, "player_death", [], ["total_rounds_played"]) | ||
let wantedTicks = deaths.map(x => x.tick) | ||
let round_ends = parseEvent(pathToDemo, "round_end") | ||
let tickData = parseTicks(pathToDemo, ["is_alive", "team_name", "team_rounds_total"], wantedTicks) | ||
let maxRound = Math.max(...deaths.map(x => x.total_rounds_played)) | ||
|
||
for (let i = 0; i <= maxRound; i++){ | ||
let res = find_if_1vx(deaths, i, round_ends, tickData, X); | ||
if (res != undefined){ | ||
console.log("Round", i , res, "clutched a 1 v", X); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from demoparser2 import DemoParser | ||
|
||
# 1vX | ||
X = 4 | ||
path_to_demo = "path/to/demo.dem" | ||
|
||
def find_if_1vx(deaths, round_idx, round_ends, df, X): | ||
for _, death in deaths.iterrows(): | ||
if death["total_rounds_played"] == round_idx: | ||
|
||
subdf = df[df["tick"] == death["tick"]] | ||
ct_alive = subdf[(subdf["team_name"] == "CT") & (subdf["is_alive"] == True)] | ||
t_alive = subdf[(subdf["team_name"] == "TERRORIST") & (subdf["is_alive"] == True)] | ||
# 3 = CT | ||
if len(ct_alive) == 1 and len(t_alive) == X and round_ends.iloc[round_idx]["winner"] == 3: | ||
return ct_alive["name"].iloc[0] | ||
# 2 = T | ||
if len(t_alive) == 1 and len(ct_alive) == X and round_ends.iloc[round_idx]["winner"] == 2: | ||
return t_alive["name"].iloc[0] | ||
|
||
|
||
parser = DemoParser(path_to_demo) | ||
deaths = parser.parse_event("player_death", other=["total_rounds_played"]) | ||
round_ends = parser.parse_event("round_end") | ||
df = parser.parse_ticks(["is_alive", "team_name", "team_rounds_total"], ticks=deaths["tick"].to_list()) | ||
max_round = deaths["total_rounds_played"].max() + 1 | ||
|
||
for round_idx in range(0, max_round): | ||
clutcher_steamid = find_if_1vx(deaths, round_idx, round_ends, df, X) | ||
if clutcher_steamid != None: | ||
print("a", clutcher_steamid, file) | ||
|