Skip to content

Commit 34a7802

Browse files
committed
added pause/cutscene gamestate
1 parent 0c5d55f commit 34a7802

File tree

3 files changed

+42
-17
lines changed

3 files changed

+42
-17
lines changed

python/uwapi/interop.py

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,11 @@ class UwUnitStateFlags(IntFlag):
9494

9595
class UwPlayerStateFlags(IntFlag):
9696
Nothing = 0
97-
Loaded = 1 << 0
98-
Pause = 1 << 1
99-
Disconnected = 1 << 2
100-
Admin = 1 << 3
97+
Disconnected = 1 << 0
98+
Admin = 1 << 1
99+
Loaded = 1 << 2
100+
Pause = 1 << 3
101+
SkipCutscene = 1 << 4
101102

102103
class UwPlayerConnectionClassEnum(Enum):
103104
Nothing = 0
@@ -108,16 +109,19 @@ class UwPlayerConnectionClassEnum(Enum):
108109

109110
class UwForceStateFlags(IntFlag):
110111
Nothing = 0
111-
Winner = 1 << 0
112-
Defeated = 1 << 1
113-
Disconnected = 1 << 2
112+
Disconnected = 1 << 0
113+
Winner = 1 << 1
114+
Defeated = 1 << 2
114115

115116
class UwGameStateEnum(Enum):
116117
Nothing = 0
117118
Session = 1
118119
Preparation = 2
119120
Game = 3
120121
Finish = 4
122+
Paused = 5
123+
CutscenePaused = 6
124+
CutsceneRunning = 7
121125

122126
class UwTaskTypeEnum(Enum):
123127
Nothing = 0
@@ -280,9 +284,9 @@ class UwPlayerComponent:
280284

281285
@dataclass
282286
class UwPlayerAiConfigComponent:
283-
dumbness: float
287+
difficulty: float
284288
aggressive: float
285-
stretched: float
289+
stretching: float
286290
expansive: float
287291

288292
@dataclass
@@ -545,17 +549,23 @@ def uwAdminSetMapSelection(self, path: str) -> None:
545549
path_ = self._str_pytoc(path)
546550
self._api.uwAdminSetMapSelection(path_)
547551

552+
def uwAdminSetGameSpeed(self, speed: float) -> None:
553+
self._api.uwAdminSetGameSpeed(speed)
554+
555+
def uwAdminSetWeatherSpeed(self, speed: float, offset: float) -> None:
556+
self._api.uwAdminSetWeatherSpeed(speed, offset)
557+
548558
def uwAdminStartGame(self) -> None:
549559
self._api.uwAdminStartGame()
550560

551561
def uwAdminTerminateGame(self) -> None:
552562
self._api.uwAdminTerminateGame()
553563

554-
def uwAdminSetGameSpeed(self, speed: float) -> None:
555-
self._api.uwAdminSetGameSpeed(speed)
564+
def uwAdminPauseGame(self, pause: bool) -> None:
565+
self._api.uwAdminPauseGame(pause)
556566

557-
def uwAdminSetWeatherSpeed(self, speed: float, offset: float) -> None:
558-
self._api.uwAdminSetWeatherSpeed(speed, offset)
567+
def uwAdminSkipCutscene(self) -> None:
568+
self._api.uwAdminSkipCutscene()
559569

560570
def uwAdminAddAi(self) -> None:
561571
self._api.uwAdminAddAi()
@@ -570,6 +580,10 @@ def uwAdminPlayerSetName(self, playerId: int, name: str) -> None:
570580
name_ = self._str_pytoc(name)
571581
self._api.uwAdminPlayerSetName(playerId, name_)
572582

583+
def uwAdminPlayerAiConfig(self, playerId: int, config: UwPlayerAiConfigComponent) -> None:
584+
config_ = self._UwPlayerAiConfigComponent_pytoc(config)
585+
self._api.uwAdminPlayerAiConfig(playerId, config_)
586+
573587
def uwAdminPlayerJoinForce(self, playerId: int, forceId: int) -> None:
574588
self._api.uwAdminPlayerJoinForce(playerId, forceId)
575589

@@ -1284,7 +1298,15 @@ def _UwPlayerComponent_ctopy(self, val) -> UwPlayerComponent:
12841298
return UwPlayerComponent(self._str_ctopy(val.name), int(val.nameLength), int(val.steamUserId), int(val.force), float(val.progress), int(val.ping), UwPlayerStateFlags(val.state), UwPlayerConnectionClassEnum(val.playerConnectionClass))
12851299

12861300
def _UwPlayerAiConfigComponent_ctopy(self, val) -> UwPlayerAiConfigComponent:
1287-
return UwPlayerAiConfigComponent(float(val.dumbness), float(val.aggressive), float(val.stretched), float(val.expansive))
1301+
return UwPlayerAiConfigComponent(float(val.difficulty), float(val.aggressive), float(val.stretching), float(val.expansive))
1302+
1303+
def _UwPlayerAiConfigComponent_pytoc(self, val: UwPlayerAiConfigComponent):
1304+
r = self._ffi.new("UwPlayerAiConfigComponent *")
1305+
r.difficulty = val.difficulty
1306+
r.aggressive = val.aggressive
1307+
r.stretching = val.stretching
1308+
r.expansive = val.expansive
1309+
return r
12881310

12891311
def _UwForceComponent_ctopy(self, val) -> UwForceComponent:
12901312
return UwForceComponent(list[float]([float(val.color[i]) for i in range(3)]), int(val.score), int(val.killCount), int(val.lossCount), int(val.finishTimestamp), int(val.intendedTeam), int(val.intendedRace), UwForceStateFlags(val.state))

sphinx/source/bots/setup.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The shared library is distributed together with the game.
66
The uwapi repository contains c/c++ headers for all functions and structures provided by the library.
77
Furthermore, it contains convenient wrappers for Python and C# for easy start.
88

9+
.. important::
10+
Do *not* use Flatpak or Snap for Steam on Linux.
11+
912
Steam Appid Txt
1013
---------------
1114

sphinx/source/bots/troubleshooting.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
Troubleshooting
22
===============
33

4-
.. important::
5-
Do *not* use Flatpak for Steam on Linux.
6-
74
.. dropdown:: Unable to load DLL 'unnatural-uwapi-hard'
85

96
Make sure you have installed Unnatural Worlds in Steam.
@@ -20,6 +17,9 @@ Troubleshooting
2017

2118
Make sure that Steam is running and logged in.
2219
It must run under the same user as the program.
20+
21+
Also make sure that you have copied the steam_appid.txt file correctly.
22+
2323
Do not use any containerization.
2424

2525
.. dropdown:: Linux laptop with switchable GPUs

0 commit comments

Comments
 (0)