-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathField.html
More file actions
455 lines (385 loc) · 15.9 KB
/
Copy pathField.html
File metadata and controls
455 lines (385 loc) · 15.9 KB
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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Field - Field model. : OpenKore source code documentation</title>
<link rel="stylesheet" type="text/css" href="openkore.css">
<link rel="stylesheet" type="text/css" href="highlight.css">
<!-- Fix broken PNG transparency for IE/Win5-6+ -->
<!--[if gte IE 5.5000]>
<script type="text/javascript" src="pngfix.js"></script>
<![endif]-->
</head>
<body>
<div id="title">OpenKore source code documentation</div>
<div id="navigation">
<ul>
<li><a href="http://www.openkore.com/">Main website</a></li>
<li><a href="index.html">Table of contents</a></li>
<li><b>Field</b></li>
</ul>
</div>
<div id="main">
<h1>Field - Field model.</h1>
The Field class represents a field in the game. A field is a set of blocks.
each block has a specific type, like 'walkable', 'not walkable', 'water',
'cliff', etc.
<p>
This class is closely related to the .fld file, as used by OpenKore.
See <a href="http://wiki.openkore.com/index.php/Field_file_format">http://wiki.openkore.com/index.php/Field_file_format</a>
for more information.
<p>
This class is a hash and has the following hash items:
<ul>
<li><tt>name</tt> - The name of the field, like 'prontera' and '0021@cata'. This is not always the same as baseName.
You should not access this item directly; use the <a href="Field.html#$Field->name"><code>$Field->name()</code></a> method instead.</li>
<li><tt>baseName</tt> - The name of the field, which is the base name of the field without the extension.
This is not always the same as name: for example,
descName: Training Ground, name: 'new_1-2', field file: 'new_zone01.fld', baseName: 'new_1-2'
descName: Catacombs, name: '0021@cata', field file: '1@cata.fld', baseName: '1@cata'</li>
<li><tt>width</tt> - The field's width. You should not access this item directly; use <a href="Field.html#$Field->width"><code>$Field->width()</code></a> instead.</li>
<li><tt>height</tt> - The field's height. You should not access this item directly; use <a href="Field.html#$Field->width"><code>$Field->width()</code></a> instead.</li>
<li><tt>rawMap</tt> - The raw map data. Contains information about which blocks you can walk on (byte 0),
and which not (byte 1).</li>
<li><tt>dstMap</tt> - The distance map data. Used by pathfinding.
</li>
</ul>
<p><table class="functionIndex">
<tr><th colspan="3">Functions in this module</th></tr><tr onclick="location.href='#Field->new';">
<td class="return-type"></td>
<td class="func"><a href="#Field->new">Field->new</a></td>
<td class="decl">(options...)</td>
</tr><tr onclick="location.href='#$Field->baseName';">
<td class="return-type">String</td>
<td class="func"><a href="#$Field->baseName">$Field->baseName</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$Field->descName';">
<td class="return-type">String</td>
<td class="func"><a href="#$Field->descName">$Field->descName</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$Field->descString';">
<td class="return-type">String</td>
<td class="func"><a href="#$Field->descString">$Field->descString</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$Field->getBlock';">
<td class="return-type">int</td>
<td class="func"><a href="#$Field->getBlock">$Field->getBlock</a></td>
<td class="decl">(<span class="type">int</span> x, int y)</td>
</tr><tr onclick="location.href='#$Field->height';">
<td class="return-type">int</td>
<td class="func"><a href="#$Field->height">$Field->height</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$Field->instanceID';">
<td class="return-type">String</td>
<td class="func"><a href="#$Field->instanceID">$Field->instanceID</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$Field->isCity';">
<td class="return-type">String</td>
<td class="func"><a href="#$Field->isCity">$Field->isCity</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$Field->isSnipable';">
<td class="return-type">boolean</td>
<td class="func"><a href="#$Field->isSnipable">$Field->isSnipable</a></td>
<td class="decl">(<span class="type">int</span> x, int y)</td>
</tr><tr onclick="location.href='#$Field->isWalkable';">
<td class="return-type">boolean</td>
<td class="func"><a href="#$Field->isWalkable">$Field->isWalkable</a></td>
<td class="decl">(<span class="type">int</span> x, int y)</td>
</tr><tr onclick="location.href='#$Field->loadByName';">
<td class="return-type">void</td>
<td class="func"><a href="#$Field->loadByName">$Field->loadByName</a></td>
<td class="decl">(<span class="type">String</span> name, [boolean loadDistanceMap = true])</td>
</tr><tr onclick="location.href='#$Field->loadFile';">
<td class="return-type">void</td>
<td class="func"><a href="#$Field->loadFile">$Field->loadFile</a></td>
<td class="decl">(<span class="type">String</span> filename, [boolean loadDistanceMap = true])</td>
</tr><tr onclick="location.href='#$Field->name';">
<td class="return-type">String</td>
<td class="func"><a href="#$Field->name">$Field->name</a></td>
<td class="decl">()</td>
</tr><tr onclick="location.href='#$Field->width';">
<td class="return-type">int</td>
<td class="func"><a href="#$Field->width">$Field->width</a></td>
<td class="decl">()</td>
</tr>
</table>
<p><table class="functionIndex">
<tr><th colspan="3">Map image API</th></tr><tr onclick="location.href='#$Field->image';">
<td class="return-type">String</td>
<td class="func"><a href="#$Field->image">$Field->image</a></td>
<td class="decl">(<span class="type">[String</span> format])</td>
</tr>
</table>
<p><hr class="details_sep">
<h2>Details</h2>
<div class="details">
<p>
<div class="function"><a name="$Field->baseName"></a>
<h3>$Field->baseName</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$Field->baseName</strong>()
</dt>
<dd>
<div class="desc">Returns the field's base name.
ex. prontera, new_1-2 (alias), 1@cata (instanced)</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->descName"></a>
<h3>$Field->descName</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$Field->descName</strong>()
</dt>
<dd>
<div class="desc">Returns the field's descriptive name.
ex.
Prontera City, Capital of Rune Midgard
Training Ground
Catacombs</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->descString"></a>
<h3>$Field->descString</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$Field->descString</strong>()
</dt>
<dd>
<div class="desc">Returns the field's descriptive string.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->getBlock"></a>
<h3>$Field->getBlock</h3>
<dl>
<dt class="decl">
<span class="return-type"> int</span> <strong>$Field->getBlock</strong>(<span class="type">int</span> x, int y)
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>x, y</code> : A coordinate on the field.</dd>
<dt class="returns"><strong>Returns:</strong></dt>
<dd class="returns">The type for this block. This is one of the block type constants.</dd>
</dl><p>
<div class="desc">Get the type for the block on the specified coordinate. This type is an integer, which
corresponds with the values specified in the field file format specification:
<a href="http://www.openkore.com/wiki/index.php/Field_file_format#The_FLD_file_format">http://www.openkore.com/wiki/index.php/Field_file_format#The_FLD_file_format</a>
<p>
If you want to check whether the block is walkable, use <code>$field->isWalkable()</code> instead.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->height"></a>
<h3>$Field->height</h3>
<dl>
<dt class="decl">
<span class="return-type"> int</span> <strong>$Field->height</strong>()
</dt>
<dd>
<div class="desc">Returns the field's height, in blocks.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->image"></a>
<h3>$Field->image</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$Field->image</strong>(<span class="type">[String</span> format])
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>format</code> : image format</dd>
</dl><p>
<div class="desc">Path to file with map image, autogenerated if needed.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->instanceID"></a>
<h3>$Field->instanceID</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$Field->instanceID</strong>()
</dt>
<dd>
<div class="desc">Returns the field's instanceID
ex. in 0021@cata, 002 is the instanceID</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->isCity"></a>
<h3>$Field->isCity</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$Field->isCity</strong>()
</dt>
<dd>
<div class="desc">Returns wether the field is a city.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->isSnipable"></a>
<h3>$Field->isSnipable</h3>
<dl>
<dt class="decl">
<span class="return-type"> boolean</span> <strong>$Field->isSnipable</strong>(<span class="type">int</span> x, int y)
</dt>
<dd>
<div class="desc">Check whether you can snipe through ($x,$y) on this field.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->isWalkable"></a>
<h3>$Field->isWalkable</h3>
<dl>
<dt class="decl">
<span class="return-type"> boolean</span> <strong>$Field->isWalkable</strong>(<span class="type">int</span> x, int y)
</dt>
<dd>
<div class="desc">Check whether you can walk on ($x,$y) on this field.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->loadByName"></a>
<h3>$Field->loadByName</h3>
<dl>
<dt class="decl">
<span class="return-type"> void</span> <strong>$Field->loadByName</strong>(<span class="type">String</span> name, [boolean loadDistanceMap = true])
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>name</code> : The name of the field to load. E.g. "prontera".</dd>
<dd class="param"><code>loadDistanceMap</code> : Whether to also load the associated distance map file.</dd>
</dl><p>
<div class="desc">Load a field file based on it's name. The actual field file to load is automatically
determined based on the field name, the field files folder, whether the field file
is compressed, etc.
<p>
This method is like calling the constructor with the 'name' argument,
but allows you to load a field inside this Field object.
<p>
If <code>$loadDistanceMap</code> is set to false, then <code>$self</code>->{dstMap} will be undef.
<p>
Throws FileNotFoundException if a field file cannot be found for the specified
field name.
Throws IOException if a read error occured while reading the field file
and/or the distance map file.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->loadFile"></a>
<h3>$Field->loadFile</h3>
<dl>
<dt class="decl">
<span class="return-type"> void</span> <strong>$Field->loadFile</strong>(<span class="type">String</span> filename, [boolean loadDistanceMap = true])
</dt>
<dd>
<dl class="params_and_returns">
<dt class="params"><strong>Parameters:</strong></dt>
<dd class="param"><code>filename</code> : The filename of the field file to load.</dd>
<dd class="param"><code>loadDistanceMap</code> : Whether to also load the associated distance map file.</dd>
</dl><p>
<div class="desc">Load the specified field file (.fld file). This is like calling the constructor
with the 'file' argument, but allows you to load a field inside this Field object.
<p>
If <code>$loadDistanceMap</code> is set to false, then <code>$self</code>->{dstMap} will be undef.
<p>
Throws FileNotFoundException if the specified file does not exist.
Throws IOException if a read error occured while reading the field file
and/or the distance map file.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->name"></a>
<h3>$Field->name</h3>
<dl>
<dt class="decl">
<span class="return-type"> String</span> <strong>$Field->name</strong>()
</dt>
<dd>
<div class="desc">Returns the field's name.
ex. prontera, new_1-2 (alias), 0021@cata (instance)</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="$Field->width"></a>
<h3>$Field->width</h3>
<dl>
<dt class="decl">
<span class="return-type"> int</span> <strong>$Field->width</strong>()
</dt>
<dd>
<div class="desc">Returns the field's width, in blocks.</div>
</dd>
</dl>
</div>
<p><hr class="function_sep"><p>
<div class="function"><a name="Field->new"></a>
<h3>Field->new</h3>
<dl>
<dt class="decl">
<span class="return-type"> </span><strong>Field->new</strong>(options...)
</dt>
<dd>
<div class="desc">Create a new Load a field (.fld) file. This function also loads an associated .dist file
(the distance map file), which is used by pathfinding (for wall avoidance support).
If the associated .dist file does not exist, it will be created.
<p>
This function also supports gzip-compressed field files (.fld.gz). If the .fld file cannot
be found, but the corresponding .fld.gz file can be found, this function will load that
instead and decompress its data on-the-fly.
<p>
Allowed options:
<p>
<ul>
<li><tt>file</tt> - The file to load.</li>
<li><tt>name</tt> - The name of the field to load.</li>
<li><tt>loadDistanceMap</tt> (optional) - Whether to also load the distance map. By default, this is true.
</li>
</ul>
<p>
You must specify either the 'file' option or the 'name' option. If you do not, an
ArgumentException will be thrown. For example:
<pre class="example">
new <span class="hl kwd">Field</span><span class="hl sym">(</span>name <span class="hl sym">=></span> <span class="hl str">"new_1-1"</span><span class="hl sym">);</span>
new <span class="hl kwd">Field</span><span class="hl sym">(</span>file <span class="hl sym">=></span> <span class="hl str">"/path/to/prontera.fld"</span><span class="hl sym">);</span>
new <span class="hl kwd">Field</span><span class="hl sym">();</span> <span class="hl slc"># Error: an ArgumentException will be thrown</span>
</pre>
<p>
Throws FileNotFoundException if the field file does not exist (if the 'file' parameter is used),
or if a field file cannot be found for the specified field name (if the 'name' parameter is used).<br>
Throws IOException if an error occured while reading the field file.</div>
</dd>
</dl>
</div>
</div>
<p><hr><p>
<div id="footer">
<ul>
<li><a href="http://validator.w3.org/check?uri=referer" title="Valid HTML 4.01!"><img src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" height="31" width="88"></a></li>
<li><a href="http://www.mozilla.com/" title="Get Firefox - Take Back the Web"><img width="104" height="32" src="http://www.mozilla.org/products/firefox/buttons/getfirefox_small.png" alt="Get Firefox - Take Back the Web"></a></li>
<li><a href="http://www.mozilla.com/" title="If you were looking at this page in any browser but Microsoft Internet Explorer, it would look and run better and faster"><img width="45" height="45" src="http://linuxart.com/img/noIE-small.png" alt="If you were looking at this page in any browser but Microsoft Internet Explorer, it would look and run better and faster"></a></li>
</ul>
Last modified: Fri Nov 16 10:05:11 2012
</div>
</div>
</body>
</html>