How to use the demofile.DemoFile function in demofile

To help you get started, we’ve selected a few demofile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github shoffing / csgo-demo-scripts / src / damage_dealt_inferno / extract_damage.js View on Github external
const parsers$ = INFERNO_DEMOS.map(DEMO_FILE => {
    let attacks = [];
    let plants = [];

    let demo = new demofile.DemoFile();

    let getTeam = (player) => {
        if (_.includes(demo.teams[demofile.TEAM_CTS].members.map(p => p.userId), player.userId)) {
            return "CT";
        }
        return "T";
    };

    // Wait for the first round, we don't care about the warm-up.
    let gameStarted = false;
    demo.gameEvents.on("round_start", e => {
        console.log(`=== ROUND #${demo.gameRules.roundsPlayed} STARTED IN ${DEMO_FILE} ===`);
        gameStarted = true;
    });

    // Record bomb plant position and information
github shoffing / csgo-demo-scripts / src / movement / extract_movement.js View on Github external
const parsers$ = GAME_DEMOS.map(DEMO_FILE => {
    let playerPositions = {};

    let demo = new demofile.DemoFile();

    let getTeam = (player) => {
        if (_.includes(demo.teams[demofile.TEAM_CTS].members.map(p => p && p.userId), player.userId)) {
            return "CT";
        }
        return "T";
    };

    // Wait for the first round, we don't care about the warm-up.
    let gameStarted = false;
    let lastRoundNumber = -1;
    demo.gameEvents.on("round_start", e => {
        if (demo.gameRules.roundsPlayed > lastRoundNumber) {
            console.log(`=== ROUND #${demo.gameRules.roundsPlayed} STARTED IN ${DEMO_FILE} ===`);
            demo.players
                .filter(player => player.isAlive)
github shoffing / csgo-demo-scripts / src / 1vn / extract_1vn.js View on Github external
const parsers = UNPARSED_DEMOS_BATCH.map(DEMO_FILE => {
                    const demo = new demofile.DemoFile();

                    const gameStarts$ = fromEvent(demo.gameEvents, 'round_start').pipe(
                        rxop.first(),
                    );
                    const gameEnds$ = fromEvent(demo, 'end').pipe(
                        rxop.first(),
                    );

                    // Some demos have round_end not round_officially_ended. Some are the other way around.
                    // So we'll use both and do the best we can with that.
                    let lastRoundScore = {};
                    const roundEndsWinner$ = fromEvent(demo.gameEvents, 'round_end').pipe(
                        rxop.filter(e => (e.winner === demofile.TEAM_TERRORISTS || e.winner === demofile.TEAM_CTS) && e.reason < 11),
                        rxop.map(e => {
                            if (e.winner === demofile.TEAM_TERRORISTS) return {winner: 'T'};
                            else if (e.winner === demofile.TEAM_CTS) return {winner: 'CT'};
github vlakreeh / csgo-heatmap-generator / src / parser.ts View on Github external
return new Promise((resolve, reject) => {
        let demo = new DemoFile();

        demo.on("end", () => resolve(result));

        demo.gameEvents.on("player_death", (event: any) => {
            const victim = demo.entities.getByUserId(event.userid);
            const attacker = demo.entities.getByUserId(event.attacker);

            pushDeathPoint(result.deathPoints, victim, result.mapData);
            pushDeathPoint(result.killPoints, attacker, result.mapData);
        });

        demo.on("start", async () => {
            console.log(`Parsing ${demo.header.mapName}...`);

            const overlayInfo = await parseOverlayInformation(csgoDirectory, demo.header.mapName);
            result.mapData = {
github shoffing / csgo-demo-scripts / src / defuse / extract_defuses.js View on Github external
const parsers = UNPARSED_DEMOS_BATCH.map(DEMO_FILE => {
            const demo = new demofile.DemoFile();

            let C4_TIMER;
            const gameStarts$ = fromEvent(demo.gameEvents, "round_start").pipe(
              rxop.first(),
              rxop.tap(() => {
                C4_TIMER = demo.conVars.vars.mp_c4timer
                  ? parseFloat(demo.conVars.vars.mp_c4timer)
                  : 40;
              })
            );
            const gameEnds$ = fromEvent(demo, "end").pipe(rxop.first());

            const plants$ = fromEvent(demo.gameEvents, "bomb_planted").pipe(
              rxop.map(e => ({ ...e, time: demo.currentTime }))
            );
            const defuses$ = fromEvent(demo.gameEvents, "bomb_defused").pipe(

demofile

A node.js library for parsing Counter-Strike Global Offensive (CSGO) demo files. The library is also Browserify-able, and a standalone bundle that you can `<script src="...">` is available in [browser/bundle.js](browser/bundle.js).

MIT
Latest version published 1 year ago

Package Health Score

54 / 100
Full package analysis