Skip to content

Commit a43f691

Browse files
committed
ping, ai config, mana, regen; pathfinding docs
1 parent f70eafa commit a43f691

File tree

13 files changed

+266
-51
lines changed

13 files changed

+266
-51
lines changed

c/uwapi/uwapi/modules/botsAdmin.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ extern "C"
2929
UNNATURAL_API void uwAdminSendSuggestedCameraFocus(uint32 position);
3030
UNNATURAL_API void uwAdminSetAutomaticSuggestedCameraFocus(bool enabled);
3131
UNNATURAL_API void uwAdminSendChat(const char *msg, UwChatTargetFlags flags, uint32 targetId);
32+
UNNATURAL_API void uwAdminSendPing(uint32 position, UwPingEnum ping, uint32 targetForce);
3233

3334
#endif
3435

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 = 35;
37+
static const uint32 UW_VERSION = 36;
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 UwPingEnum
54+
{
55+
UwPingEnum_None = 0,
56+
UwPingEnum_Attention = 1,
57+
UwPingEnum_Attack = 2,
58+
UwPingEnum_Defend = 3,
59+
UwPingEnum_Rally = 4,
60+
UwPingEnum_Build = 5,
61+
UwPingEnum_Evacuate = 6,
62+
} UwPingEnum;
63+
5364
typedef enum UwPathStateEnum
5465
{
5566
UwPathStateEnum_None = 0,

c/uwapi/uwapi/modules/components.h

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ extern "C"
5252
typedef enum UwUnitStateFlags
5353
{
5454
UwUnitStateFlags_None = 0,
55-
UwUnitStateFlags_Shooting = 1 << 0,
55+
UwUnitStateFlags_Shooting = 1 << 0, // reloading
5656
UwUnitStateFlags_Processing = 1 << 1, // processing recipe
5757
UwUnitStateFlags_Rebuilding = 1 << 2, // changing recipe
5858
UwUnitStateFlags_Stalling = 1 << 3, // usually due to maximumProcessingOutput
59+
UwUnitStateFlags_Damaged = 1 << 4, // less than half life
5960
} UwUnitStateFlags;
6061
typedef struct UwUnitComponent
6162
{
@@ -70,6 +71,12 @@ extern "C"
7071
} UwLifeComponent;
7172
UNNATURAL_API bool uwFetchLifeComponent(UwEntityPtr entity, UwLifeComponent *data);
7273

74+
typedef struct UwManaComponent
75+
{
76+
sint32 mana;
77+
} UwManaComponent;
78+
UNNATURAL_API bool uwFetchManaComponent(UwEntityPtr entity, UwManaComponent *data);
79+
7380
typedef struct UwMoveComponent
7481
{
7582
uint32 posStart;
@@ -93,19 +100,19 @@ extern "C"
93100
} UwRecipeComponent;
94101
UNNATURAL_API bool uwFetchRecipeComponent(UwEntityPtr entity, UwRecipeComponent *data);
95102

96-
typedef struct UwUpdateTimestampComponent
97-
{
98-
uint32 timestamp;
99-
} UwUpdateTimestampComponent;
100-
UNNATURAL_API bool uwFetchUpdateTimestampComponent(UwEntityPtr entity, UwUpdateTimestampComponent *data);
101-
102103
typedef struct UwRecipeStatisticsComponent
103104
{
104105
uint32 timestamps[3];
105106
uint32 completed;
106107
} UwRecipeStatisticsComponent;
107108
UNNATURAL_API bool uwFetchRecipeStatisticsComponent(UwEntityPtr entity, UwRecipeStatisticsComponent *data);
108109

110+
typedef struct UwLogisticsTimestampComponent
111+
{
112+
uint32 timestamp;
113+
} UwLogisticsTimestampComponent;
114+
UNNATURAL_API bool uwFetchLogisticsTimestampComponent(UwEntityPtr entity, UwLogisticsTimestampComponent *data);
115+
109116
typedef struct UwPriorityComponent
110117
{
111118
UwPriorityEnum priority;
@@ -124,6 +131,12 @@ extern "C"
124131
} UwAttachmentComponent;
125132
UNNATURAL_API bool uwFetchAttachmentComponent(UwEntityPtr entity, UwAttachmentComponent *data);
126133

134+
typedef struct UwPingComponent
135+
{
136+
UwPingEnum ping;
137+
} UwPingComponent;
138+
UNNATURAL_API bool uwFetchPingComponent(UwEntityPtr entity, UwPingComponent *data);
139+
127140
typedef enum UwPlayerStateFlags
128141
{
129142
UwPlayerStateFlags_None = 0,
@@ -153,6 +166,15 @@ extern "C"
153166
} UwPlayerComponent;
154167
UNNATURAL_API bool uwFetchPlayerComponent(UwEntityPtr entity, UwPlayerComponent *data);
155168

169+
typedef struct UwPlayerAiConfigComponent
170+
{
171+
float dumbness;
172+
float aggressive; // army is frequently attacking, or mostly just defends
173+
float stretched; // army is spread into many small groups, or mostly concentrated
174+
float expansive; // takes many bases, or turtles on few
175+
} UwPlayerAiConfigComponent;
176+
UNNATURAL_API bool uwFetchPlayerAiConfigComponent(UwEntityPtr entity, UwPlayerAiConfigComponent *data);
177+
156178
typedef enum UwForceStateFlags
157179
{
158180
UwForceStateFlags_None = 0,

c/uwapi/uwapi/modules/scriptsServer.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,38 @@ extern "C"
1919
UNNATURAL_API void uwSetPosition(uint32 entity, uint32 position);
2020
UNNATURAL_API void uwSetYaw(uint32 entity, float yaw);
2121
UNNATURAL_API void uwMove(uint32 entity, uint32 position); // neighbor only
22-
UNNATURAL_API void uwMoveYaw(uint32 entity, uint32 position, float yaw);
23-
UNNATURAL_API void uwMoveTo(uint32 entity, uint32 position);
22+
UNNATURAL_API void uwMoveYaw(uint32 entity, uint32 position, float yaw); // neighbor only
23+
UNNATURAL_API void uwMoveTowards(uint32 entity, uint32 position); // performs serves-side pathfinding - use with care
2424

2525
UNNATURAL_API void uwSetLife(uint32 entity, uint32 life);
26+
UNNATURAL_API void uwSetMana(uint32 entity, uint32 mana);
2627
UNNATURAL_API void uwSetAim(uint32 entity, uint32 target); // target = 0 to remove
2728
UNNATURAL_API void uwSetRecipe(uint32 entity, uint32 recipe); // recipe = 0 to remove
2829
UNNATURAL_API void uwSetPriority(uint32 entity, UwPriorityEnum priority);
29-
UNNATURAL_API void uwSetCooldown(uint32 entity, uint32 ticks);
30+
UNNATURAL_API void uwSetShootingCooldown(uint32 entity, uint32 ticks); // ticks = 0 to remove cooldown
31+
UNNATURAL_API void uwSetRegenCooldown(uint32 entity, uint32 ticks); // ticks = 0 to remove cooldown
32+
UNNATURAL_API void uwSetProcessingCooldown(uint32 entity, uint32 ticks); // ticks = 0 to remove cooldown
33+
UNNATURAL_API void uwSetDecay(uint32 entity, uint32 ticks); // ticks = -1 to remove decay
3034

3135
UNNATURAL_API void uwSetAmount(uint32 entity, uint32 amount);
3236
UNNATURAL_API void uwSetAttached(uint32 entity, uint32 target); // target = 0 to detach
3337

3438
UNNATURAL_API uint32 uwCreateForce(void);
3539
UNNATURAL_API void uwDestroyForce(uint32 force);
36-
UNNATURAL_API void uwSetPlayerForce(uint32 player, uint32 force);
3740
UNNATURAL_API void uwSetForceColor(uint32 force, float r, float g, float b);
3841
UNNATURAL_API void uwSetForceFinish(uint32 force, bool winner, bool defeated);
3942
UNNATURAL_API void uwSetForceStartingTeam(uint32 force, uint32 team);
4043
UNNATURAL_API void uwSetForceStartingPosition(uint32 force, uint32 position);
4144
UNNATURAL_API void uwSetForeignPolicy(uint32 force1, uint32 force2, UwForeignPolicyEnum policy);
4245

46+
UNNATURAL_API uint32 uwCreateAiPlayer(void);
47+
// UNNATURAL_API void uwDestroyAiPlayer(uint32 player);
48+
UNNATURAL_API void uwSetPlayerAiConfig(uint32 player, const UwPlayerAiConfigComponent *config);
49+
UNNATURAL_API void uwSetPlayerForce(uint32 player, uint32 force);
50+
4351
UNNATURAL_API void uwStandardVictoryConditions(bool enable);
44-
UNNATURAL_API void uwSendChat(const char *msg, UwChatTargetFlags flags, uint32 target);
52+
UNNATURAL_API void uwSendChat(const char *msg, UwChatTargetFlags flags, uint32 targetId);
53+
UNNATURAL_API void uwSendPing(uint32 position, UwPingEnum ping, uint32 targetForce);
4554

4655
UNNATURAL_API void uwPrint(const char *msg);
4756
UNNATURAL_API uint32 uwRand(void);

c/uwapi/uwapi/modules/world.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ extern "C"
2727
{
2828
float damage;
2929
float shootingRange;
30+
float splashRadius;
3031
float defense;
32+
float regenSpeed;
3133
float movementSpeed;
3234
float processingSpeed;
3335
} UwUnitUpgrades;

c/uwapi/uwapi/scripts.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define unnatural_uwapi_scripts_hpp_zhgfa8g4
33

44
#include <vector>
5+
#include <cstring> // memcpy
56

67
#include "scripts.h"
78

@@ -12,12 +13,12 @@ namespace uw
1213
{
1314
std::vector<std::remove_cv_t<T>> res;
1415
res.resize(cnt);
15-
memcpy(res.data(), data, cnt * sizeof(T));
16+
std::memcpy(res.data(), data, cnt * sizeof(T));
1617
return res;
1718
}
1819

1920
template<class S>
20-
requires(requires { S::data; })
21+
requires(requires { S::data; })
2122
auto makeVector(const S *src)
2223
{
2324
return makeVector(src->data, src->count);

csharp/uwapi/admin.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Unnatural
22
{
33
using ChatTargetFLags = Interop.UwChatTargetFlags;
4+
using PingEnum = Interop.UwPingEnum;
45

56
public static class Admin
67
{
@@ -98,5 +99,10 @@ public static void SendChat(string msg, ChatTargetFLags flags, uint id = uint.Ma
9899
{
99100
Interop.uwAdminSendChat(msg, flags, id);
100101
}
102+
103+
public static void SendPing(uint position, PingEnum ping, uint id)
104+
{
105+
Interop.uwAdminSendPing(position, ping, id);
106+
}
101107
}
102108
}

0 commit comments

Comments
 (0)