Skip to content

Commit a2f5bf3

Browse files
committed
start of uw version 34
document area queries document hard library
1 parent d484e99 commit a2f5bf3

File tree

25 files changed

+1303
-939
lines changed

25 files changed

+1303
-939
lines changed

c/uwapi/uwapi/bots.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "modules/botsAdmin.h"
77
#include "modules/botsConnection.h"
88
#include "modules/commands.h"
9+
#include "modules/components.h"
910
#include "modules/game.h"
1011
#include "modules/map.h"
1112
#include "modules/prototypes.h"

c/uwapi/uwapi/modules/botsConnection.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@ extern "C"
1010

1111
#ifdef UNNATURAL_BOTS
1212

13+
// initialization
14+
1315
UNNATURAL_API void uwInitialize(uint32 version);
1416
UNNATURAL_API void uwDeinitialize(void);
1517

1618
typedef void (*UwExceptionCallbackType)(const char *message);
1719
UNNATURAL_API void uwSetExceptionCallback(UwExceptionCallbackType callback);
1820

21+
// logging
22+
1923
typedef enum UwSeverityEnum
2024
{
2125
UwSeverityEnum_Note = 0,
@@ -36,6 +40,8 @@ extern "C"
3640
UNNATURAL_API void uwInitializeConsoleLogger(void);
3741
UNNATURAL_API void uwLog(UwSeverityEnum severity, const char *message);
3842

43+
// connection state
44+
3945
typedef enum UwConnectionStateEnum
4046
{
4147
UwConnectionStateEnum_None = 0,
@@ -47,6 +53,8 @@ extern "C"
4753
UNNATURAL_API void uwSetConnectionStateCallback(UwConnectionStateCallbackType callback);
4854
UNNATURAL_API UwConnectionStateEnum uwConnectionState(void);
4955

56+
// connect
57+
5058
UNNATURAL_API void uwSetConnectStartGui(bool enabled, const char *extraCmdParams);
5159
UNNATURAL_API void uwSetConnectAsObserver(bool observer);
5260
UNNATURAL_API bool uwConnectFindLan(uint64 timeoutMicroseconds);
@@ -57,6 +65,31 @@ extern "C"
5765
UNNATURAL_API bool uwTryReconnect(void);
5866
UNNATURAL_API void uwDisconnect(void);
5967

68+
// my player
69+
70+
UNNATURAL_API void uwSetPlayerName(const char *name);
71+
UNNATURAL_API void uwSetPlayerColor(float r, float g, float b); // [0 .. 1]
72+
UNNATURAL_API void uwSetPlayerRace(uint32 raceProto);
73+
74+
typedef struct UwMyPlayer
75+
{
76+
uint32 playerEntityId;
77+
uint32 forceEntityId;
78+
bool primaryController;
79+
bool admin;
80+
} UwMyPlayer;
81+
UNNATURAL_API bool uwMyPlayer(UwMyPlayer *data);
82+
83+
typedef struct UwAssistConfig
84+
{
85+
bool logistics;
86+
bool aiming;
87+
bool fighting;
88+
} UwAssistConfig;
89+
UNNATURAL_API void uwSetAssistConfig(const UwAssistConfig *config);
90+
91+
// performance
92+
6093
typedef struct UwPerformanceStatistics
6194
{
6295
float gameSpeed;

c/uwapi/uwapi/modules/commands.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,6 @@ extern "C"
4444
} UwOrders;
4545
UNNATURAL_API void uwOrders(uint32 unit, UwOrders *data);
4646

47-
typedef enum UwPathStateEnum
48-
{
49-
UwPathStateEnum_None = 0,
50-
UwPathStateEnum_Searching = 1,
51-
UwPathStateEnum_Impossible = 2,
52-
UwPathStateEnum_NotFound = 3,
53-
UwPathStateEnum_Recompute = 4,
54-
UwPathStateEnum_Found = 5,
55-
UwPathStateEnum_Finished = 6,
56-
} UwPathStateEnum;
57-
UNNATURAL_API UwPathStateEnum uwUnitPathState(uint32 unitId);
58-
5947
UNNATURAL_API void uwCommandPlaceConstruction(uint32 constructionProto, uint32 position, float yaw, uint32 recipeProto, UwPriorityEnum priority); // recipeProto may be 0
6048
UNNATURAL_API void uwCommandSetRecipe(uint32 unitOrConstructionId, uint32 recipeProto);
6149
UNNATURAL_API void uwCommandSetPriority(uint32 unitOrConstructionId, UwPriorityEnum priority);

c/uwapi/uwapi/modules/common.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C"
3434
typedef uint64_t uint64;
3535
typedef int64_t sint64;
3636

37-
static const uint32 UW_VERSION = 33;
37+
static const uint32 UW_VERSION = 34;
3838
static const uint32 UW_GameTicksPerSecond = 20;
3939

4040
typedef struct UwIds
@@ -50,6 +50,17 @@ extern "C"
5050
UwPriorityEnum_High = 2,
5151
} UwPriorityEnum;
5252

53+
typedef enum UwPathStateEnum
54+
{
55+
UwPathStateEnum_None = 0,
56+
UwPathStateEnum_Searching = 1,
57+
UwPathStateEnum_Impossible = 2,
58+
UwPathStateEnum_NotFound = 3,
59+
UwPathStateEnum_Recompute = 4,
60+
UwPathStateEnum_Found = 5,
61+
UwPathStateEnum_Finished = 6,
62+
} UwPathStateEnum;
63+
5364
typedef enum UwForeignPolicyEnum
5465
{
5566
UwForeignPolicyEnum_None = 0,

c/uwapi/uwapi/modules/components.h

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
#ifndef unnatural_uwapi_components_h_dxc2f4hz8werz
2+
#define unnatural_uwapi_components_h_dxc2f4hz8werz
3+
4+
#include "common.h"
5+
6+
#ifdef __cplusplus
7+
extern "C"
8+
{
9+
#endif
10+
11+
#ifdef UNNATURAL_BOTS
12+
typedef struct UwEntity UwEntity;
13+
typedef UwEntity *UwEntityPtr;
14+
UNNATURAL_API UwEntityPtr uwEntityPointer(uint32 id);
15+
UNNATURAL_API uint32 uwEntityId(UwEntityPtr entity);
16+
UNNATURAL_API void uwModifiedEntities(UwIds *data);
17+
#endif
18+
19+
#ifdef UNNATURAL_SCRIPTS
20+
typedef uint32 UwEntityPtr;
21+
#endif
22+
23+
UNNATURAL_API void uwAllEntities(UwIds *data);
24+
UNNATURAL_API bool uwEntityExists(uint32 id);
25+
26+
typedef struct UwProtoComponent
27+
{
28+
uint32 proto;
29+
} UwProtoComponent;
30+
UNNATURAL_API bool uwFetchProtoComponent(UwEntityPtr entity, UwProtoComponent *data);
31+
32+
typedef struct UwOwnerComponent
33+
{
34+
uint32 force;
35+
} UwOwnerComponent;
36+
UNNATURAL_API bool uwFetchOwnerComponent(UwEntityPtr entity, UwOwnerComponent *data);
37+
38+
typedef struct UwControllerComponent
39+
{
40+
uint32 player;
41+
uint32 timestamp;
42+
} UwControllerComponent;
43+
UNNATURAL_API bool uwFetchControllerComponent(UwEntityPtr entity, UwControllerComponent *data);
44+
45+
typedef struct UwPositionComponent
46+
{
47+
uint32 position;
48+
float yaw;
49+
} UwPositionComponent;
50+
UNNATURAL_API bool uwFetchPositionComponent(UwEntityPtr entity, UwPositionComponent *data);
51+
52+
typedef enum UwUnitStateFlags
53+
{
54+
UwUnitStateFlags_None = 0,
55+
UwUnitStateFlags_Shooting = 1 << 0,
56+
UwUnitStateFlags_Processing = 1 << 1, // processing recipe
57+
UwUnitStateFlags_Rebuilding = 1 << 2, // changing recipe
58+
UwUnitStateFlags_Stalling = 1 << 3, // usually due to maximumProcessingOutput
59+
} UwUnitStateFlags;
60+
typedef struct UwUnitComponent
61+
{
62+
UwUnitStateFlags state;
63+
uint32 killCount;
64+
} UwUnitComponent;
65+
UNNATURAL_API bool uwFetchUnitComponent(UwEntityPtr entity, UwUnitComponent *data);
66+
67+
typedef struct UwLifeComponent
68+
{
69+
sint32 life;
70+
} UwLifeComponent;
71+
UNNATURAL_API bool uwFetchLifeComponent(UwEntityPtr entity, UwLifeComponent *data);
72+
73+
typedef struct UwMoveComponent
74+
{
75+
uint32 posStart;
76+
uint32 posEnd;
77+
uint32 tickStart;
78+
uint32 tickEnd;
79+
float yawStart;
80+
float yawEnd;
81+
} UwMoveComponent;
82+
UNNATURAL_API bool uwFetchMoveComponent(UwEntityPtr entity, UwMoveComponent *data);
83+
84+
typedef struct UwAimComponent
85+
{
86+
uint32 target;
87+
} UwAimComponent;
88+
UNNATURAL_API bool uwFetchAimComponent(UwEntityPtr entity, UwAimComponent *data);
89+
90+
typedef struct UwRecipeComponent
91+
{
92+
uint32 recipe;
93+
} UwRecipeComponent;
94+
UNNATURAL_API bool uwFetchRecipeComponent(UwEntityPtr entity, UwRecipeComponent *data);
95+
96+
typedef struct UwUpdateTimestampComponent
97+
{
98+
uint32 timestamp;
99+
} UwUpdateTimestampComponent;
100+
UNNATURAL_API bool uwFetchUpdateTimestampComponent(UwEntityPtr entity, UwUpdateTimestampComponent *data);
101+
102+
typedef struct UwRecipeStatisticsComponent
103+
{
104+
uint32 timestamps[3];
105+
uint32 completed;
106+
} UwRecipeStatisticsComponent;
107+
UNNATURAL_API bool uwFetchRecipeStatisticsComponent(UwEntityPtr entity, UwRecipeStatisticsComponent *data);
108+
109+
typedef struct UwPriorityComponent
110+
{
111+
UwPriorityEnum priority;
112+
} UwPriorityComponent;
113+
UNNATURAL_API bool uwFetchPriorityComponent(UwEntityPtr entity, UwPriorityComponent *data);
114+
115+
typedef struct UwAmountComponent
116+
{
117+
uint32 amount;
118+
} UwAmountComponent;
119+
UNNATURAL_API bool uwFetchAmountComponent(UwEntityPtr entity, UwAmountComponent *data);
120+
121+
typedef struct UwAttachmentComponent
122+
{
123+
uint32 target;
124+
} UwAttachmentComponent;
125+
UNNATURAL_API bool uwFetchAttachmentComponent(UwEntityPtr entity, UwAttachmentComponent *data);
126+
127+
typedef enum UwPlayerStateFlags
128+
{
129+
UwPlayerStateFlags_None = 0,
130+
UwPlayerStateFlags_Loaded = 1 << 0,
131+
UwPlayerStateFlags_Pause = 1 << 1,
132+
UwPlayerStateFlags_Disconnected = 1 << 2,
133+
UwPlayerStateFlags_Admin = 1 << 3,
134+
} UwPlayerStateFlags;
135+
typedef enum UwPlayerConnectionClassEnum
136+
{
137+
UwPlayerConnectionClassEnum_None = 0,
138+
UwPlayerConnectionClassEnum_Computer = 1,
139+
UwPlayerConnectionClassEnum_VirtualReality = 2,
140+
UwPlayerConnectionClassEnum_Robot = 3,
141+
UwPlayerConnectionClassEnum_UwApi = 4,
142+
} UwPlayerConnectionClassEnum;
143+
typedef struct UwPlayerComponent
144+
{
145+
char name[28];
146+
uint32 nameLength;
147+
uint64 steamUserId;
148+
uint32 force;
149+
float progress;
150+
uint32 ping;
151+
UwPlayerStateFlags state;
152+
UwPlayerConnectionClassEnum playerConnectionClass;
153+
} UwPlayerComponent;
154+
UNNATURAL_API bool uwFetchPlayerComponent(UwEntityPtr entity, UwPlayerComponent *data);
155+
156+
typedef enum UwForceStateFlags
157+
{
158+
UwForceStateFlags_None = 0,
159+
UwForceStateFlags_Winner = 1 << 0,
160+
UwForceStateFlags_Defeated = 1 << 1,
161+
UwForceStateFlags_Disconnected = 1 << 2,
162+
} UwForceStateFlags;
163+
typedef struct UwForceComponent
164+
{
165+
float color[3];
166+
uint64 score;
167+
uint32 killCount;
168+
uint32 lossCount;
169+
uint32 finishTimestamp;
170+
uint32 intendedTeam;
171+
uint32 intendedRace;
172+
UwForceStateFlags state;
173+
} UwForceComponent;
174+
UNNATURAL_API bool uwFetchForceComponent(UwEntityPtr entity, UwForceComponent *data);
175+
176+
typedef struct UwForceDetailsComponent
177+
{
178+
uint64 killValue;
179+
uint64 lossValue;
180+
uint32 startingPosition;
181+
uint32 race;
182+
} UwForceDetailsComponent;
183+
UNNATURAL_API bool uwFetchForceDetailsComponent(UwEntityPtr entity, UwForceDetailsComponent *data);
184+
185+
typedef struct UwForeignPolicyComponent
186+
{
187+
uint32 forces[2];
188+
UwForeignPolicyEnum policy;
189+
} UwForeignPolicyComponent;
190+
UNNATURAL_API bool uwFetchForeignPolicyComponent(UwEntityPtr entity, UwForeignPolicyComponent *data);
191+
192+
typedef struct UwDiplomacyProposalComponent
193+
{
194+
uint32 offeror;
195+
uint32 offeree;
196+
UwForeignPolicyEnum proposal;
197+
} UwDiplomacyProposalComponent;
198+
UNNATURAL_API bool uwFetchDiplomacyProposalComponent(UwEntityPtr entity, UwDiplomacyProposalComponent *data);
199+
200+
#ifdef __cplusplus
201+
} // extern C
202+
#endif
203+
204+
#endif // unnatural_uwapi_components_h_dxc2f4hz8werz

0 commit comments

Comments
 (0)