Comments (14)
Mabe add the values from m_szTeamFlagImage and m_szTeamLogoImage as well, could be useful.
from demofile.
See e41ca9d, I've added isSpotted, isSpottedBy, allSpotters, hasSpotted, allSpotted and isFriendly functions to the Player class.
from demofile.
Completely agree - as it stands the library is quite low-level. In the near future (i.e. this month), I plan to add functions to the Entity class like:
getOrigin
getOwner
(for getting the thrower of grenades)
And methods to a new Player class such as:
getViewAngles
getSteamId
getUserId
getWeapons
Watch this space :)
from demofile.
Is it possible to determine distance from one entity to another?
If demofile hasn't some player to player distance map, then I think each player entity has position
property, so you can calculate distance with simple vector manipulation.
magnitude = Math.sqrt(v.x * v.x + v.y * v.y + v.z * v.z) // or use dot product
It should be easier if position or euler angles properties are transformed to some Vector
objects, for easier manipulation (https://evanw.github.io/lightgl.js/docs/vector.html for ref.)
Of course above distance is straight line from player A to player B, so it's not real move from A to B distance. If you want calculate this, you would need to create proper structure for that (pathfinding
problems).
from demofile.
@mavrick - what do you think of these provisional API additions? I've got it working locally, but wondering if there are any other functions you think would be useful:
Entity:
- getPosition
- getOwner
- getTeamNumber
Player:
- getHealth
- getEyeAngles
- getAccount
- getLifeState
- isAlive
- getUserInfo
- getUserId
- getSteamId
- getName
- isFakePlayer
- isHltv
- getArmor
- getPlaceName
- getActiveWeapon
- getWeapons
- isInBombZone
- isInBuyZone
- isDefusing
- hasDefuser
- hasHelmet
- getKills
- getAssists
- getDeaths
- hasC4
Entities:
- getByUserId
from demofile.
Maybe insted of getTeamNumber something like getTeam? And maybe a Team class for all that info would be great. Keep up the good work!
from demofile.
That makes sense :) I've also made them getter properties instead of functions too.
from demofile.
@derpalmer I've added:
Team:
- teamNumber
- players
- clanName
- teamName
- score
- scoreFirstHalf
- scoreSecondHalf
Anything else?
from demofile.
Hey mate,
These additional options are a great start! Using the demo files to rebuild match stats will be much easier now.
For player
what about:
- getBank
Also, I was thinking what about round information:
round
- getRound (int)
- isKnife (bool)
- score (object of teams with running score for this round)
- getWinner (teamId) - round winner
- bombPlanted (bool)
- bombDefused (bool)
- getRoundMVP
Some additional things I'd like for data analysis if possible, would be:
- Ability to determine if an entity is a player and if they are an ally or enemy
isAlly()
- Entities in FOV (who/what can the player currently see on the screen during an event)
visibileEntitiesInFov()
- All available entities within FOV
availableEntitiesInFov()
- Ability to determine is the crosshair/eyeAngle is on an entity at a given event.
hasEntityInFocus()
Examples:
var entities = player.visibileEntitiesInFov();
for(var k in entities)
{
var entity = entities[k];
if(entity.isPlayer() == true && player.hasEntityInFocus(entity) == true)
{
console.log("player is on the screen and we're locked on");
if(entity.isAlly(player) == true)
{
console.log("they are on the same team")
}
else
{
console.log("the enemy has been found");
}
}
}
or, on a kill event:
player.on("kill", function(event, entity)
{
if(entity.isVisible() == true)
{
// possible knife or gun kill
console.log("kill was visible on screen");
}
else
{
// wall bang, grenade, molly kill
console.log("kill was made offscreen");
console.log(event.killType()); // what was the kill from?
}
});
Then using them altogether, example:
player.on("eyeAngles", function(event)
{
var entities = event.availableEntitiesInFov();
for(var k in entities)
{
var entity = entities[k];
if(
entity.isPlayer() == true &&
player.hasEntityInFocus(entity) == true &&
entity.isAlly(player) == false &&
entity.isVisible() == false
)
{
console.log("player is aiming at someone through a wall or door");
}
}
});
I'm just writing 'freehand' for the above examples, they are in no way accurate based on current documentation.
I'll add some more tonight when I get home.
from demofile.
Thanks for the thorough feedback.
For
player
what about:
- getBank
Use player.account
.
round
- getRound (int)
- isKnife (bool)
- score (object of teams with running score for this round)
- getWinner (teamId) - round winner
- bombPlanted (bool)
- bombDefused (bool)
- getRoundMVP
Most of this information is available in the round_end
and round_mvp
events, alongside Team#score
. Unfortunately I don't think there's a way to determine if a round was a 'knife round'.
- Ability to determine if an entity is a player and if they are an ally or enemy
isAlly()
This should be do-able, just need to check whether the team numbers match or if mp_teammates_are_enemies is set.
- Entities in FOV (who/what can the player currently see on the screen during an event)
visibileEntitiesInFov()
- All available entities within FOV
availableEntitiesInFov()
- Ability to determine is the crosshair/eyeAngle is on an entity at a given event.
hasEntityInFocus()
Unfortunately none of these will be viable (besides possibly availableEntitiesInFov
). We need to be able to trace lines across the game world, which we can't do unless we have a full 3D representation of the level loaded into memory. This would be beyond the scope of this library.
from demofile.
Awesome, based on those additions does this look correct:
demo.entities.on('change', function()
{
console.dir(arguments);
});
{ '0':
{ entity:
Player {
_demo: [Object],
index: 10,
classId: 35,
serialNum: 923,
props: [Object],
clientSlot: 9 },
tableName: 'm_iMatchStats_KillReward',
varName: '003',
oldValue: 0,
newValue: 200 } }
demo.entities.on('change', function(data)
{
var Entity = data.entity;
var tableName = data.tableName;
var varName = data.varName;
var filters = [ 'm_bIsWalking', 'm_flLowerBodyYawTarget', 'm_bStrafing', 'm_angEyeAngles', 'm_bIsScoped' ];
if(tableName == 'DT_CSPlayer' && filters.indexOf(varName) != -1)
{
var playerEntities = Entity.allSpotted;
for(var k in playerEntities)
{
var playerEntity = playerEntities[k];
if(playerEntity.isFriendly(Entity.teamNumber) == false)
{
console.log("we've spotted an enemy");
}
}
}
});
Is it possible to determine distance from one entity to another?
from demofile.
And what about more generic information, like current map
for example?
Is there any good external reference, which shows what data is saved in these stringtables
, gameevents
etc.?
from demofile.
@cinkonaap the current map is available in DemoFile#header. I don't believe there is a reference as to what's in string tables. For events, see: https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events
from demofile.
@cinkonaap thanks for that. I will have a crack at it.
from demofile.
Related Issues (20)
- Valve Matchmaking Encrypted Chat HOT 6
- trouble while complie dumpfile.ts HOT 2
- Some Player Stats did not appear
- Illegal offset HOT 2
- error TS2532: Object is possibly 'undefined' HOT 1
- Documentation missing properties HOT 2
- Some demos missing `round_announce_match_start` HOT 3
- Wrong parse streams with transformation HOT 1
- Game event buytime_ended triggers only once HOT 3
- Is it possible to find out the skin of a weapon? HOT 1
- GOTV+ Broadcasting HOT 13
- demo.teams[0] `members` property is always empty HOT 1
- Events not firing
- itemPurchase Event - Cost HOT 1
- ServerRankUpdate doesnt work anymore HOT 3
- Is it possible to get the colors (blue, green, orange, yellow, purple) from players?
- isAlive not always working HOT 1
- Will this work with new Counter Strike 2? HOT 1
- m_iMatchStats_Deaths not sorted properly HOT 2
- CS2 Demo Support HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from demofile.