Skip to content

Commit

Permalink
report precise locations from parse
Browse files Browse the repository at this point in the history
when parsing ward/hero locations, add m_vec to m_cell location to get precise location, convert locations to floats rather than ints
  • Loading branch information
thot-experiment committed May 16, 2024
1 parent ae7e7de commit d3bbc1e
Showing 1 changed file with 32 additions and 9 deletions.
41 changes: 32 additions & 9 deletions src/main/java/opendota/Parse.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public class Entry {
public Integer gold;
public Integer lh;
public Integer xp;
public Integer x;
public Integer y;
public Integer z;
public Float x;
public Float y;
public Float z;
public Float stuns;
public Integer hero_id;
public transient List<Item> hero_inventory;
Expand Down Expand Up @@ -128,6 +128,10 @@ public Entry(Integer time) {
}
}

private Float getPreciseLocation (Integer cell, Float vec) {
return (cell*128.0f+vec)/128;
}

private class Item {
String id;
// Charges can be used to determine how many items are stacked together on
Expand Down Expand Up @@ -724,8 +728,15 @@ public void onTickStart(Context ctx, boolean synthetic) {
// get the hero's coordinates
if (e != null) {
// System.err.println(e);
entry.x = getEntityProperty(e, "CBodyComponent.m_cellX", null);
entry.y = getEntityProperty(e, "CBodyComponent.m_cellY", null);
//CBodyComponent.m_cell[XY] * 128 + CBodyComponent.m_vec[XY]
Integer cx = getEntityProperty(e, "CBodyComponent.m_cellX", null);
Integer cy = getEntityProperty(e, "CBodyComponent.m_cellY", null);

Float vx = getEntityProperty(e, "CBodyComponent.m_vecX", null);
Float vy = getEntityProperty(e, "CBodyComponent.m_vecY", null);

entry.x = getPreciseLocation(cx,vx);
entry.y = getPreciseLocation(cy,vy);
// System.err.format("%s, %s\n", entry.x, entry.y);
// get the hero's entity name, ex: CDOTA_Hero_Zuus
entry.unit = e.getDtClass().getDtName();
Expand Down Expand Up @@ -955,14 +966,26 @@ public void onWardExistenceChanged(Context ctx, Entity e) {
private Entry buildWardEntry(Context ctx, Entity e) {
Entry entry = new Entry(time);
boolean isObserver = !e.getDtClass().getDtName().contains("TrueSight");
Integer x = getEntityProperty(e, "CBodyComponent.m_cellX", null);
Integer y = getEntityProperty(e, "CBodyComponent.m_cellY", null);
Integer z = getEntityProperty(e, "CBodyComponent.m_cellZ", null);

Integer cx = getEntityProperty(e, "CBodyComponent.m_cellX", null);
Integer cy = getEntityProperty(e, "CBodyComponent.m_cellY", null);
Integer cz = getEntityProperty(e, "CBodyComponent.m_cellZ", null);

Float vx = getEntityProperty(e, "CBodyComponent.m_vecX", null);
Float vy = getEntityProperty(e, "CBodyComponent.m_vecY", null);
Float vz = getEntityProperty(e, "CBodyComponent.m_vecZ", null);

Float x = getPreciseLocation(cx,vx);
Float y = getPreciseLocation(cy,vy);
Float z = getPreciseLocation(cz,vz);

Integer life_state = getEntityProperty(e, "m_lifeState", null);
Integer[] pos = { x, y };
Float[] pos = { x, y };

entry.x = x;
entry.y = y;
entry.z = z;

entry.type = isObserver ? "obs" : "sen";
entry.entityleft = life_state == 1;
entry.key = Arrays.toString(pos);
Expand Down

0 comments on commit d3bbc1e

Please sign in to comment.