Skip to content

Commit

Permalink
Added ANGLE, PITCH, ROLL, VELOCITY_X/Y/Z GameVariables
Browse files Browse the repository at this point in the history
Former-commit-id: f8fc04e
  • Loading branch information
mwydmuch committed Jul 5, 2017
1 parent 2fc6207 commit 2891c6b
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 15 deletions.
4 changes: 4 additions & 0 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
- Added `setRenderScreenFlashes` and `setRenderAllFrames` methods.
- Added `viz_ignore_render_mode` CVAR which disables overriding rendering settings.

#### GameVariables
- Added `ANGLE`, `PITCH`, `ROLL`, `VELOCITY_X/Y/Z` GameVariables.

#### Missing config keys
- Added support for `DEATHCOUNT`, `USER31` - `USER60`, `PLAYER_NUMBER`, `PLAYER_COUNT`, `PLAYER1_FRAGCOUNT` - `PLAYER16_FRAGCOUNT`, `POSITION_X/Y/Z` GameVariables in the config file.
- Added support for `ALTATTACK` Button in the config file.

#### Java specific
- Fixed `makeAction`.
- Added missing 'POSITION_X/Y/Z' Game Variables.

#### Python specific
- Added manual GIL management for better performance when used with Python threads.
Expand Down
16 changes: 11 additions & 5 deletions doc/Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,23 @@ Enum type that defines all variables that can be obtained from the game.
- **DEATHCOUNT**
- **HEALTH** - Can be higher then 100!
- **ARMOR** - Can be higher then 100!
- **DEAD** - True if player is dead.
- **ON_GROUND** - True if player is on the ground (not in the air).
- **ATTACK_READY** - True if attack can be performed.
- **ALTATTACK_READY** - True if altattack can be performed.
- **DEAD** - True if the player is dead.
- **ON_GROUND** - True if the player is on the ground (not in the air).
- **ATTACK_READY** - True if the attack can be performed.
- **ALTATTACK_READY** - True if the altattack can be performed.
- **SELECTED_WEAPON** - Selected weapon's number.
- **SELECTED_WEAPON_AMMO** - Ammo for selected weapon.
- **AMMO0** - **AMMO9** - Number of ammo for weapon in N slot.
- **WEAPON0** - **WEAPON9** - Number of weapons in N slot.
- **POSITION_X** - Position of player
- **POSITION_X** - Position of the player, not available if `viz_nocheat` is enabled.
- **POSITION_Y**
- **POSITION_Z**
- **ANGLE** - Position of the player, not available if `viz_nocheat` is enabled.
- **PITCH**
- **ROLL**
- **VELOCITY_X** - Velocity of the player, not available if `viz_nocheat` is enabled.
- **VELOCITY_Y**
- **VELOCITY_Z**
- **PLAYER_NUMBER** - Player's number in multiplayer game.
- **PLAYER_COUNT** - Number of players in multiplayer game.
- **PLAYER1_FRAGCOUNT** - **PLAYER16_FRAGCOUNT** - Number of N player's frags
Expand Down
6 changes: 6 additions & 0 deletions include/ViZDoomTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ namespace vizdoom{
POSITION_X,
POSITION_Y,
POSITION_Z,
ANGLE,
PITCH,
ROLL,
VELOCITY_X,
VELOCITY_Y,
VELOCITY_Z,

PLAYER_NUMBER,
PLAYER_COUNT,
Expand Down
7 changes: 7 additions & 0 deletions src/lib/ViZDoomConfigLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ namespace vizdoom {
if (str == "position_x") return POSITION_X;
if (str == "position_y") return POSITION_Y;
if (str == "position_z") return POSITION_Z;
if (str == "angle") return ANGLE;
if (str == "pitch") return PITCH;
if (str == "roll") return ROLL;
if (str == "velocity_x") return VELOCITY_X;
if (str == "velocity_y") return VELOCITY_Y;
if (str == "velocity_z") return VELOCITY_Z;

if (str == "player_number") return PLAYER_NUMBER;
if (str == "player_count") return PLAYER_COUNT;

Expand Down
4 changes: 2 additions & 2 deletions src/lib/ViZDoomController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,8 +932,8 @@ namespace vizdoom {
return this->gameState->PLAYER_AMMO[var - AMMO0];
else if (var >= WEAPON0 && var <= WEAPON9)
return this->gameState->PLAYER_WEAPON[var - WEAPON0];
else if(var >= POSITION_X && var <= POSITION_Z)
return this->gameState->PLAYER_POSITION[var - POSITION_X];
else if(var >= POSITION_X && var <= VELOCITY_Z)
return this->gameState->PLAYER_MOVEMENT[var - POSITION_X];
else if(var >= USER1 && var <= USER60)
return this->gameState->MAP_USER_VARS[var - USER1];
else if (var >= PLAYER1_FRAGCOUNT && var <= PLAYER16_FRAGCOUNT)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ViZDoomSharedMemory.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ namespace vizdoom {
int PLAYER_AMMO[SLOT_COUNT];
int PLAYER_WEAPON[SLOT_COUNT];

double PLAYER_POSITION[3];
double PLAYER_MOVEMENT[9];

bool PLAYER_READY_TO_RESPAWN;
unsigned int PLAYER_NUMBER;
Expand Down
6 changes: 6 additions & 0 deletions src/lib/ViZDoomUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ namespace vizdoom {
CASE_ENUM(POSITION_X)
CASE_ENUM(POSITION_Y)
CASE_ENUM(POSITION_Z)
CASE_ENUM(ANGLE)
CASE_ENUM(PITCH)
CASE_ENUM(ROLL)
CASE_ENUM(VELOCITY_X)
CASE_ENUM(VELOCITY_Y)
CASE_ENUM(VELOCITY_Z)
CASE_ENUM(PLAYER_NUMBER)
CASE_ENUM(PLAYER_COUNT)
CASE_ENUM(PLAYER1_FRAGCOUNT)
Expand Down
9 changes: 9 additions & 0 deletions src/lib_java/java_classes/enums/GameVariable.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ public enum GameVariable {
WEAPON7,
WEAPON8,
WEAPON9,
POSITION_X,
POSITION_Y,
POSITION_Z,
ANGLE,
PITCH,
ROLL,
VELOCITY_X,
VELOCITY_Y,
VELOCITY_Z,
USER1,
USER2,
USER3,
Expand Down
6 changes: 6 additions & 0 deletions src/lib_lua/ViZDoomLuaModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ extern "C" int luaopen_vizdoom(lua_State *luaState){
ENUM_VAL_2_LUA(POSITION_X),
ENUM_VAL_2_LUA(POSITION_Y),
ENUM_VAL_2_LUA(POSITION_Z),
ENUM_VAL_2_LUA(ANGLE),
ENUM_VAL_2_LUA(PITCH),
ENUM_VAL_2_LUA(ROLL),
ENUM_VAL_2_LUA(VELOCITY_X),
ENUM_VAL_2_LUA(VELOCITY_Y),
ENUM_VAL_2_LUA(VELOCITY_Z),
ENUM_VAL_2_LUA(USER1),
ENUM_VAL_2_LUA(USER2),
ENUM_VAL_2_LUA(USER3),
Expand Down
6 changes: 6 additions & 0 deletions src/lib_python/ViZDoomPythonModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ BOOST_PYTHON_MODULE(vizdoom)
ENUM_VAL_2_PYT(POSITION_X)
ENUM_VAL_2_PYT(POSITION_Y)
ENUM_VAL_2_PYT(POSITION_Z)
ENUM_VAL_2_PYT(ANGLE)
ENUM_VAL_2_PYT(PITCH)
ENUM_VAL_2_PYT(ROLL)
ENUM_VAL_2_PYT(VELOCITY_X)
ENUM_VAL_2_PYT(VELOCITY_Y)
ENUM_VAL_2_PYT(VELOCITY_Z)
ENUM_VAL_2_PYT(USER1)
ENUM_VAL_2_PYT(USER2)
ENUM_VAL_2_PYT(USER3)
Expand Down
22 changes: 16 additions & 6 deletions src/vizdoom/src/viz_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ inline double VIZ_FixedToDouble(fixed_t fixed){
return static_cast<double>(fixed) / 65536.0;
}

inline double VIZ_AngleToDouble(angle_t angle) {
return static_cast<double>(angle) / ANGLE_MAX * 360;
}

int VIZ_CheckItem(FName name) {
if(VIZ_PLAYER.mo != NULL) {
AInventory *item = VIZ_PLAYER.mo->FindInventory(name);
Expand Down Expand Up @@ -143,9 +147,9 @@ void VIZ_GameStateInit(){
strncpy(vizGameStateSM->VERSION_STR, VIZ_VERSION_STR, 8);
vizGameStateSM->SM_SIZE = vizSMSize;

vizGameStateSM->PLAYER_POSITION[0] = 0;
vizGameStateSM->PLAYER_POSITION[1] = 0;
vizGameStateSM->PLAYER_POSITION[2] = 0;
for(int i = 0; i < 9; ++i){
vizGameStateSM->PLAYER_MOVEMENT[i] = 0;
}
}

void VIZ_GameStateUpdate(){
Expand Down Expand Up @@ -202,9 +206,15 @@ void VIZ_GameStateTic(){
vizGameStateSM->PLAYER_DEAD = VIZ_PLAYER.playerstate == PST_DEAD || VIZ_PLAYER.mo->health <= 0;

if(!*viz_nocheat) {
vizGameStateSM->PLAYER_POSITION[0] = VIZ_FixedToDouble(VIZ_PLAYER.mo->__pos.x);
vizGameStateSM->PLAYER_POSITION[1] = VIZ_FixedToDouble(VIZ_PLAYER.mo->__pos.y);
vizGameStateSM->PLAYER_POSITION[2] = VIZ_FixedToDouble(VIZ_PLAYER.mo->__pos.z);
vizGameStateSM->PLAYER_MOVEMENT[0] = VIZ_FixedToDouble(VIZ_PLAYER.mo->__pos.x);
vizGameStateSM->PLAYER_MOVEMENT[1] = VIZ_FixedToDouble(VIZ_PLAYER.mo->__pos.y);
vizGameStateSM->PLAYER_MOVEMENT[2] = VIZ_FixedToDouble(VIZ_PLAYER.mo->__pos.z);
vizGameStateSM->PLAYER_MOVEMENT[3] = VIZ_AngleToDouble(VIZ_PLAYER.mo->angle);
vizGameStateSM->PLAYER_MOVEMENT[4] = static_cast<double>(VIZ_PLAYER.mo->pitch) / 32768.0 * 180 / 65536.0;
vizGameStateSM->PLAYER_MOVEMENT[5] = VIZ_AngleToDouble(VIZ_PLAYER.mo->roll);
vizGameStateSM->PLAYER_MOVEMENT[6] = VIZ_FixedToDouble(VIZ_PLAYER.mo->velx);
vizGameStateSM->PLAYER_MOVEMENT[7] = VIZ_FixedToDouble(VIZ_PLAYER.mo->vely);
vizGameStateSM->PLAYER_MOVEMENT[8] = VIZ_FixedToDouble(VIZ_PLAYER.mo->velz);
}
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/vizdoom/src/viz_game.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ struct VIZGameState{
int PLAYER_AMMO[VIZ_GV_SLOTS_SIZE];
int PLAYER_WEAPON[VIZ_GV_SLOTS_SIZE];

double PLAYER_POSITION[3];
double PLAYER_MOVEMENT[9];

bool PLAYER_READY_TO_RESPAWN;
unsigned int PLAYER_NUMBER;
Expand Down

0 comments on commit 2891c6b

Please sign in to comment.