Skip to content

Commit

Permalink
Merge pull request #5 from PowerBroker2/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
PowerBroker2 committed Nov 12, 2020
2 parents 0e9e192 + bff9df6 commit 4cfae7f
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 613 deletions.
38 changes: 30 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
# WarThunder Library
Python and C++ libraries to query and access vehicle telemetry data while in War Thunder air battles (NOT tanks)
[![GitHub version](https://badge.fury.io/gh/PowerBroker2%2FWarThunder.svg)](https://badge.fury.io/gh/PowerBroker2%2FWarThunder) [![PyPI version](https://badge.fury.io/py/WarThunder.svg)](https://badge.fury.io/py/WarThunder)

These libraries make use of War Thunder's localhost server pages (http://localhost:8111/indicators, http://localhost:8111/state, http://localhost:8111/map.img, http://localhost:8111/map_obj.json, and http://localhost:8111/map_info.json, and more!) that the game automatically serves when you launch a game match. If it is an air battle, these pages will include JSON formatted data with valid airplane telemetry. This telemetry is then converted and returned to the calling function/user.

The data can then be easily used for any custom application (i.e. telemetry datalogger and grapher).

# Example Use-Case:
https://github.com/PowerBroker2/Thunder_Viewer
# Overview
Python package to access vehicle telemetry and match data in real-time while in War Thunder air battles (NOT tanks). Here are some things you can access/do with this package:
- Get telemetry information on your vehicle and others identified on user's mini map
- Data available for both user and other match player's vehicles:
- Location in latitude/longitude (DD)
- Heading angle
- Airspeed
- Pitch angle
- Data avilable only for user's vehicle:
- Roll angle
- Flap state
- Gear state
- Altitude
- Data on other objects identified on user's mini map
- Object's location in latitude/longitude (DD)
- Airfields have 2 locations, one for each end of the runway
- Object's faction (friendly or enemy)
- Object's type (fighter, bomber, heavy tank, etc)
- Map name
- Chat comments (anything typed into chat)
- Match events (death, crash, etc)
- Log data in an [ACMI format](https://www.tacview.net/documentation/acmi/en/) compatible with [Tacview](https://www.tacview.net/)

# To Install
`pip install WarThunder`
Expand All @@ -29,3 +44,10 @@ if __name__ == '__main__':
except KeyboardInterrupt:
print('Closing')
```

This library makes use of War Thunder's localhost server pages (http://localhost:8111/indicators, http://localhost:8111/state, http://localhost:8111/map.img, http://localhost:8111/map_obj.json, and http://localhost:8111/map_info.json, and more!) that the game automatically serves when you launch a game match. If it is an air battle, these pages will include JSON formatted data with valid airplane telemetry. This telemetry is then converted and returned to the calling function/user.

The data can then be easily used for any custom application (i.e. telemetry datalogger and grapher).

# Example Use-Case:
https://github.com/PowerBroker2/Thunder_Viewer
Binary file modified WarThunder/map.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 29 additions & 29 deletions WarThunder/mapinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,23 @@ def get_grid_info(map_img):
'ULHC_lon': 0.0,
'size_km' : 65}

def find_obj_coords(x, y, map_size, ULHC_lat, ULHC_lon):
'''
Description:
------------
Convert the provided x/y coordinate to lat/lon
'''

dist_x = x * map_size
dist_y = y * map_size
dist = hypotenuse(dist_x, dist_y)
bearing = degrees(atan2(y, x)) + 90

if bearing < 0:
bearing += 360

return coord_coord(ULHC_lat, ULHC_lon, dist, bearing)


class map_obj(object):
def __init__(self, map_obj_entry=None, map_size=None, ULHC_lat=None, ULHC_lon=None):
Expand Down Expand Up @@ -162,14 +179,14 @@ def update(self, map_obj_entry, map_size, ULHC_lat, ULHC_lon):
self.south_end = [map_obj_entry['sx'], map_obj_entry['sy']]
self.east_end = [map_obj_entry['ex'], map_obj_entry['ey']]

self.south_end_ll = self.find_obj_coords(*self.south_end,
map_size,
ULHC_lat,
ULHC_lon)
self.east_end_ll = self.find_obj_coords(*self.east_end,
map_size,
ULHC_lat,
ULHC_lon)
self.south_end_ll = find_obj_coords(*self.south_end,
map_size,
ULHC_lat,
ULHC_lon)
self.east_end_ll = find_obj_coords(*self.east_end,
map_size,
ULHC_lat,
ULHC_lon)
self.runway_dir = coord_bearing(*self.south_end_ll,
*self.east_end_ll)
except KeyError:
Expand All @@ -181,27 +198,10 @@ def update(self, map_obj_entry, map_size, ULHC_lat, ULHC_lon):

self.runway_dir = 0

self.position_ll = self.find_obj_coords(*self.position,
map_size,
ULHC_lat,
ULHC_lon)

def find_obj_coords(self, x, y, map_size, ULHC_lat, ULHC_lon):
'''
Description:
------------
Convert the provided x/y coordinate to lat/lon
'''

dist_x = x * map_size
dist_y = y * map_size
dist = hypotenuse(dist_x, dist_y)
bearing = degrees(atan2(y, x)) + 90

if bearing < 0:
bearing += 360

return coord_coord(ULHC_lat, ULHC_lon, dist, bearing)
self.position_ll = find_obj_coords(*self.position,
map_size,
ULHC_lat,
ULHC_lon)


class MapInfo(object):
Expand Down
194 changes: 0 additions & 194 deletions cpp/WTC.cpp

This file was deleted.

Loading

0 comments on commit 4cfae7f

Please sign in to comment.