Skip to content

Commit 7648de1

Browse files
committed
docs: economy and orders
1 parent 156d496 commit 7648de1

File tree

7 files changed

+169
-12
lines changed

7 files changed

+169
-12
lines changed

sphinx/source/concepts/economy.rst

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
Economy
2+
=======
3+
4+
Resources are mined from deposits, or processed from other resources.
5+
Producing units or researching upgrades works the same way as recipes.
6+
7+
.. tab-set::
8+
:sync-group: language
9+
10+
.. tab-item:: Python
11+
:sync: python
12+
13+
.. code-block:: python
14+
15+
# find closest viable position for miner:
16+
p = uw_world.find_construction_placement(DRILL_CONSTRUCTION_ID, home_position, METAL_RECIPE_ID) # recipe id is optional
17+
if p == INVALID:
18+
return
19+
20+
# place construction:
21+
uw_commands.place_construction(DRILL_CONSTRUCTION_ID, p, 0, METAL_RECIPE_ID, UwPriorityEnum.Normal) # yaw, recipe, and priority are optional
22+
23+
# recipe and priority can be changed later:
24+
uw_commands.set_recipe(own_id, ANOTHER_RECIPE_ID)
25+
uw_commands.set_priority(own_id, UwPriorityEnum.High)
26+
27+
.. tab-item:: C#
28+
:sync: csharp
29+
30+
.. code-block:: csharp
31+
32+
// find closest viable position for miner:
33+
uint p = World.FindConstructionPlacement(DRILL_CONSTRUCTION_ID, homePosition, METAL_RECIPE_ID); // recipe id is optional
34+
if (p == Entity.Invalid):
35+
return;
36+
37+
// place construction:
38+
Commands.PlaceConstruction(DRILL_CONSTRUCTION_ID, p, 0, METAL_RECIPE_ID, Interop.UwPriorityEnum.Normal); // yaw, recipe, and priority are optional
39+
40+
// recipe and priority can be changed later:
41+
Commands.SetRecipe(own_id, ANOTHER_RECIPE_ID)
42+
Commands.SetPriority(own_id, Interop.UwPriorityEnum.High)
43+
44+
.. tab-item:: C++
45+
:sync: cpp
46+
47+
.. code-block:: cpp
48+
49+
// todo
50+
51+
Logistics
52+
---------
53+
54+
Resources are automatically transported by trucks.
55+
They will fulfill tasks by their priority, and on first-come-first-serve basis.
56+
57+
.. tab-set::
58+
:sync-group: language
59+
60+
.. tab-item:: Python
61+
:sync: python
62+
63+
.. code-block:: python
64+
65+
# percentage of trucks that are idle:
66+
100.0 * uw_world.my_force_statistics().logisticsUnitsIdle / uw_world.my_force_statistics().logisticsUnitsTotal
67+
68+
.. tab-item:: C#
69+
:sync: csharp
70+
71+
.. code-block:: csharp
72+
73+
// percentage of trucks that are idle:
74+
100.0 * World.MyForceStatistics().logisticsUnitsIdle / World.MyForceStatistics().logisticsUnitsTotal
75+
76+
.. tab-item:: C++
77+
:sync: cpp
78+
79+
.. code-block:: cpp
80+
81+
// nothing

sphinx/source/concepts/entities.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Entities & Components
2-
=====================
1+
Entities
2+
========
33

44
.. epigraph::
55

@@ -103,7 +103,7 @@ It is forbidden to change eg. from unit to resource.
103103
x.Proto.Value.proto // assumes that the entity actually has Proto component
104104
105105
// access a value from the prototype:
106-
x.ProtoUnit.dps // assumes that the entity is a unit
106+
x.ProtoUnit?.dps // assumes that the entity is a unit
107107
108108
.. tab-item:: C++
109109
:sync: cpp
@@ -220,7 +220,7 @@ Contains additional state for a unit (or building).
220220
.. code-block:: csharp
221221
222222
// check if unit is Processing:
223-
(x.Unit.Value.state & UwUnitStateFlags::Processing) != 0
223+
(x.Unit.Value.state & UwUnitStateFlags.Processing) != 0
224224
225225
.. tab-item:: C++
226226
:sync: cpp

sphinx/source/concepts/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Glossary and explanation of concepts used throughout this documentation and in t
77
map
88
prototypes
99
entities
10-
resources
11-
combat
10+
economy
11+
military
1212
programState
1313
callbacks

sphinx/source/concepts/map.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,32 @@ There are multiple functions for finding tiles within some distance.
8080

8181
**Area Extended**
8282

83+
.. tab-set::
84+
:sync-group: language
85+
86+
.. tab-item:: Python
87+
:sync: python
88+
89+
.. code-block:: python
90+
91+
# find all connected tiles around home position:
92+
uw_map.area_connected(home_position, 300)
93+
94+
.. tab-item:: C#
95+
:sync: csharp
96+
97+
.. code-block:: csharp
98+
99+
// find all connected tiles around home position:
100+
Map.AreaConnected(homePosition, 300)
101+
102+
.. tab-item:: C++
103+
:sync: cpp
104+
105+
.. code-block:: cpp
106+
107+
// todo
108+
83109
Pathfinding
84110
-----------
85111
Finds fastest path for a specified type of unit from tile A to tile B.

sphinx/source/concepts/combat.rst renamed to sphinx/source/concepts/military.rst

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,61 @@
1-
Combat & Upgrades
2-
=================
1+
Military
2+
========
3+
4+
Orders
5+
------
6+
7+
.. note::
8+
Orders are usable by clients only. Server-side scripts do not have the concept of orders.
9+
10+
You can have multiple orders queued for each unit.
11+
12+
.. tab-set::
13+
:sync-group: language
14+
15+
.. tab-item:: Python
16+
:sync: python
17+
18+
.. code-block:: python
19+
20+
# get list of orders of own unit:
21+
os = uw_commands.orders(own_id)
22+
23+
# order own unit to attack enemy unit (cancels all previous orders):
24+
uw_commands.order(own_id, uw_commands.fight_to_entity(enemy_id))
25+
26+
# alternatively, enqueue attack order:
27+
o = uw_commands.fight_to_entity(enemy_id)
28+
o.priority = o.priority | UwOrderPriorityFlags.Enqueue
29+
uw_commands.order(own_id, o)
30+
31+
.. tab-item:: C#
32+
:sync: csharp
33+
34+
.. code-block:: csharp
35+
36+
// get list of orders of own unit:
37+
var os = Commands.Orders(own_id);
38+
39+
// order own unit to attack enemy unit (cancels all previous orders):
40+
Commands.Order(own_id, Commands.FightToEntity(enemy_id));
41+
42+
// alternatively, enqueue attack order:
43+
Order o = Commands.FightToEntity(enemy_id);
44+
o.priority |= Interop.UwOrderPriorityFlags.Enqueue;
45+
Commands.Order(own_id, o);
46+
47+
.. tab-item:: C++
48+
:sync: cpp
49+
50+
.. code-block:: cpp
51+
52+
// nothing
353
454
Shooting
555
--------
656

57+
Units will automatically target appropriate enemies in their vicinity.
58+
759
Requirements for shooting:
860

961
- the target is withing shooting range.

sphinx/source/concepts/prototypes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Tags may be used by both Bots and Scripts.
5959
- ``ambush`` - walks over additional terrain types.
6060
- ``artillery`` - longer range than most.
6161
- ``assault`` - good for front-line combat.
62+
- ``decoration`` - just a decoration.
63+
- ``deposit`` - contains ore; build a miner over this unit to gather resources.
6264
- ``harassment`` - good for hit-and-run attacks, especially targeting workers.
6365
- ``home`` - the center of your base. dont let it die.
6466
- ``miner`` - generates resources, usually from ore deposits.

sphinx/source/concepts/resources.rst

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)