-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfig.js
200 lines (190 loc) · 4.85 KB
/
config.js
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
// Global configuration options for IOGrid back end
module.exports = {
// Having a large world (lower player density) is more efficient.
// You can divide it up into cells to split up the workload between
// multiple CPU cores.
//WORLD_WIDTH: 4000,
//WORLD_HEIGHT: 4000,
WORLD_WIDTH: 2000,
WORLD_HEIGHT: 2000,
// Dividing the world into tall vertical strips (instead of square cells)
// tends to be more efficient (but this may vary depending on your use case
// and world size).
//WORLD_CELL_WIDTH: 1000,
//WORLD_CELL_HEIGHT: 4000,
WORLD_CELL_WIDTH: 2000,
WORLD_CELL_HEIGHT: 2000,
/*
The WORLD_CELL_OVERLAP_DISTANCE allows players/states from two different
cells on the grid to interact with one another.
States from different cells will show up in your cell controller but will have a
special 'external' property set to true.
This represents the maximum distance that two states can be from one another if they
are in different cells and need to interact with one another.
A smaller value is more efficient. Since this overlap area requires coordination
between multiple cells.
*/
WORLD_CELL_OVERLAP_DISTANCE: 150,
/*
This is the interval (in milliseconds) within which the world updates itself.
It also determines the frequency at which data is broadcast to users.
Making this value higher will boost performance and reduce bandwidth consumption
but will increase lag. 20ms is actually really fast - If you add some sort of
motion smoothing on the front end, 50ms or higher should be more than adequate.
*/
WORLD_UPDATE_INTERVAL: 20,
// Delete states which have gone stale (not being updated anymore).
WORLD_STALE_TIMEOUT: 1000,
// Coins don't move, so we will only refresh them
// once per second.
SPECIAL_UPDATE_INTERVALS: {
1000: ['coin']
},
PLAYER_DEFAULT_MOVE_SPEED: 10,
PLAYER_DIAMETER: 45,
PLAYER_MASS: 20,
// Note that the number of bots needs to be either 0 or a multiple of the number of
// worker processes or else it will get rounded up/down.
BOT_COUNT: 10,
BOT_MOVE_SPEED: 5,
BOT_MASS: 10,
BOT_DEFAULT_DIAMETER: 45,
BOT_CHANGE_DIRECTION_PROBABILITY: 0.01,
COIN_UPDATE_INTERVAL: 1000,
COIN_DROP_INTERVAL: 400,
COIN_MAX_COUNT: 5,
COIN_PLAYER_NO_DROP_RADIUS: 80,
// The probabilities need to add up to 1.
COIN_TYPES: [
{
type: 0,
value: -10, //orb1
radius: 10,
property: "score", // FIXME: mana
probability: 0.05
},
{
type: 1,
value: 20, //orb2
radius: 10,
property: "health",
probability: 0.1
},
{
type: 2,
value: 20, //orb3
radius: 10,
property: "score", // FIXME: mana
probability: 0.6
},
{
type: 3, //orb4
value: 20,
radius: 10,
property: "health",
probability: 0.25
}
],
// We can use this to filter out properties which don't need to be sent
// to the front end.
OUTBOUND_STATE_TRANSFORMERS: {
coin: genericStateTransformer,
hit: genericStateTransformer,
player: genericStateTransformer
},
HEROS_OPTIONS: [
{ // 0 bot
baseHealth: 100,
mana: 5,
radius: 10, // radius from hit
diameter: 50,
mass: 20
},
{ // hero 1
baseHealth: 100,
diameter: 100,
mass: 20,
mana: 5,
skills: [
{
type: 'melee',
damage: 10,
radius: 100 // radius from hit
},
{
type: 'range',
damage: 30,
shotSpeed: 15,
shotRange: 500,
radius: 50 // radius from hit
},
{
type:'melee' // FIXME: dash
},
{
type:'melee',
damage: 70,
radius: 200 // radius from hit
}
]
},
{ // hero 2
baseHealth: 100,
radius: 5, // radius from hit
mana: 5,
skills: [
{
type:'range',
damage: 10,
shotSpeed: 15,
shotRange: 500,
radius: 50
},
{
type:'range',
damage: 35,
shotSpeed: 25,
shotRange: 500,
radius: 100
},
{
type:'melee' // FIXME: dash
},
{
type:'melee',
damage: 70,
radius: 200 // radius from hit
}
],
diameter: 100,
mass: 20
}
]
};
var privateProps = {
ccid: true,
tcid: true,
mass: true,
speed: true,
changeDirProb: true,
repeatOp: true,
swid: true,
processed: true,
pendingGroup: true,
group: true,
version: true,
external: true,
iddle: true,
auxAttackStep: true,
auxWalkerStep: true,
lastAttackDelay: true
};
function genericStateTransformer(state) {
var clone = {};
Object.keys(state).forEach(function (key) {
if (!privateProps[key]) {
clone[key] = state[key];
}
});
return clone;
}