forked from lep/jassdoc
/
random.j
129 lines (86 loc) · 4.05 KB
/
random.j
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Randomization API
/**
Returns a random integer in the range [lowBound, highBound].
@note If lowBound > highBound then it just swaps the values.
@bug If you call `GetRandomInt(INT_MIN, INT_MAX)` or `GetRandomInt(INT_MAX, INT_MIN)`
it will always return the same value, namely `INT_MIN` or `INT_MAX`.
@note See <http://hiveworkshop.com/threads/random.286109#post-3073222> for an overview of the algorithm used.
@param lowBound
The inclusive lower bound of the random number returned
@param highBound
The inclusive higher bound of the random number returned
*/
native GetRandomInt takes integer lowBound, integer highBound returns integer
native GetRandomReal takes real lowBound, real highBound returns real
native CreateUnitPool takes nothing returns unitpool
native DestroyUnitPool takes unitpool whichPool returns nothing
native UnitPoolAddUnitType takes unitpool whichPool, integer unitId, real weight returns nothing
native UnitPoolRemoveUnitType takes unitpool whichPool, integer unitId returns nothing
native PlaceRandomUnit takes unitpool whichPool, player forWhichPlayer, real x, real y, real facing returns unit
/**
Creates an empty itempool handle.
Item pools are initially empty, but can have item-types added
to them via `ItemPoolAddItemType`. Item pools only serve for random item
placing, via `PlaceRandomItem`.
*/
native CreateItemPool takes nothing returns itempool
native DestroyItemPool takes itempool whichItemPool returns nothing
/**
Adds an item-id to the itempool.
@param whichItemPool
The itempool to add the item to
@param itemId
The rawcode of the item
@param weight
The weight of the item
The weight determines how likely it is for the item to be chose by `PlaceRandomItem`.
*/
native ItemPoolAddItemType takes itempool whichItemPool, integer itemId, real weight returns nothing
native ItemPoolRemoveItemType takes itempool whichItemPool, integer itemId returns nothing
/**
Draws a random itemid from the itempool and creates the item.
@param whichItemPool
The itempool to draw from
@param x
The x-coordinate of the item
@param y
The y-coordinate of the item
*/
native PlaceRandomItem takes itempool whichItemPool, real x, real y returns item
// Choose any random unit/item. (NP means Neutral Passive)
/**
Returns the rawcode ID of a random unit of the specified level. The unit chosen
will come from the set of units that include or are assigned to the base tileset
of the map. Passing a level of -1 is equivalent to picking a creep of any level.
If there are no units of the specified level, the returned value is 0.
@param level
The level of the units to choose from.
*/
native ChooseRandomCreep takes integer level returns integer
/**
Returns the rawcode ID of a random neutral passive building,
such as the buildings "Goblin Merchant" or "Tavern".
@note The building returned is not necessarily on the map already.
*/
native ChooseRandomNPBuilding takes nothing returns integer
/**
Returns the rawcode ID of a random item of the specified level. Passing a level
of -1 will return an item of any level. If there are no items of the specified
level, the id returned will be 0.
@param level
The level of the items to choose from. Passing a level of -1 is equivalent to any level.
@note The item returned is not chosen from preplaced items on the map, but rather any item of that level.
*/
native ChooseRandomItem takes integer level returns integer
/**
Returns the rawcode ID of a random item of the specified level and item type.
Passing a level of -1 will return an item of any level. If there are no items
of the specified level, the id returned will be 0.
@param whichType
The classification of items to choose from.
@param level
The level of the items to choose from. Passing a level of -1 is equivalent to any level.
@note The item returned is not chosen from preplaced items on the map, but rather any item of that level.
*/
native ChooseRandomItemEx takes itemtype whichType, integer level returns integer
native SetRandomSeed takes integer seed returns nothing