How to use the demofile.TEAM_TERRORISTS 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
// It's not perfect, but we can find the attacker with reasonable accuracy by finding the closest player to inflictorWorldPos.
            const attacker = _.minBy(demo.players, p => {
                return distance3(p.position, e.msg.inflictorWorldPos);
            });
            if (victim && attacker && victim.index !== attacker.index
                && attacker.isAlive && distance3(attacker.position, e.msg.inflictorWorldPos) < 50) {
                const victimTeam = getTeam(victim);
                const attackerTeam = getTeam(attacker);
                const amount = e.msg.amount;
                const weapon = attacker.weapon.className;
                // console.log(`${attacker.name} (${attackerTeam}) attacked ${victim.name} (${victimTeam}) for ${amount} damage with ${weapon}`);
                attacks.push({
                    time: demo.currentTime,
                    round: demo.gameRules.roundsPlayed,
                    score: {
                        T: demo.teams[demofile.TEAM_TERRORISTS].score,
                        CT: demo.teams[demofile.TEAM_CTS].score,
                    },
                    attacker: {
                        pos: attacker.position,
                        team: attackerTeam,
                        name: attacker.name,
                    },
                    victim: {
                        pos: victim.position,
                        team: victimTeam,
                        name: victim.name,
                    },
                    amount: amount,
                    weapon: weapon,
                });
            }
github shoffing / csgo-demo-scripts / src / 1vn / extract_1vn.js View on Github external
                        rxop.filter(e => (e.winner === demofile.TEAM_TERRORISTS || e.winner === demofile.TEAM_CTS) && e.reason < 11),
                        rxop.map(e => {
github shoffing / csgo-demo-scripts / src / 1vn / extract_1vn.js View on Github external
rxop.map(() => {
                            let tScore = demo.teams[demofile.TEAM_TERRORISTS].score;
                            let ctScore = demo.teams[demofile.TEAM_CTS].score;
                            let lastTScore = lastRoundScore[demo.teams[demofile.TEAM_TERRORISTS].clanName] || 0;
                            let lastCTScore = lastRoundScore[demo.teams[demofile.TEAM_CTS].clanName] || 0;
                            let winner = tScore > lastTScore ? 'T' : (ctScore > lastCTScore ? 'CT' : undefined);

                            lastRoundScore = {};
                            lastRoundScore[demo.teams[demofile.TEAM_TERRORISTS].clanName] = tScore;
                            lastRoundScore[demo.teams[demofile.TEAM_CTS].clanName] = ctScore;

                            return {winner};
                        }),
                    );

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 2 years ago

Package Health Score

51 / 100
Full package analysis