03. december 2002 - 19:06
#6
d2jsp Command Reference
Written by Syadasti for the d2jsp Project.
Last updated 08 October 2002 06:09 PM -0700
--------------------------------------------------------------------------------
About d2jsp
d2jsp is an embedded implementation of a JavaScript engine for executing user program code (scripts) inside Diablo II. d2jsp can be used to make Diablo II do almost anything that can be done in the game by a human player, and some things (such as knowing the immunities of monsters four screens away) that cannot. d2jsp does not attempt to exploit any bugs in Diablo II's programming, the Battle.net protocol, or the Battle.net servers.
Why JavaScript?
JavaScript combines the ease-of-use of a loosely-typed, well-documented, and widely understood programming language with capabilities that approach (but not completely match) those offered in modern object-oriented languages such as C++. JavaScript's syntax will be familiar to C++ programmers, and can be picked up fairly quickly even by those with little C++ experience. JavaScript has the advantage of running inside a virtual machine which makes doing damaging things to the operating system, files, or other applications virtually (pun intended) impossible.
How do I learn about writing d2jsp scripts?
Besides this document, which provides a variety of example code snippets, the sample scripts distributed with d2jsp are a good place to start understanding the JavaScript language in the context of Diablo II bot programming. If you need additional learning material, check out WebTeacher.com's JavaScript for the Total Non-Programmer. You might also find the VisiBone JavaScript Online Quick Reference handy.
--------------------------------------------------------------------------------
On notation:
"int" indicates an integer value. Values with decimal places are not permitted. Valid examples of integers:
235 // positive decimal number
-10 // negative decimal number
0x3A // Hexadecimal
0xDeadBeef // Funny hexadecimal
me.x // Player X coordinate
"string" indicates a string value. String literals must be enclosed in parenthesis ( ). Valid examples of strings:
"d2jsp r0x0rz!!!" // string literal
me.name // Player name (string value from object property)
"2 + 2 = " + 5 // composite string value with integer
"Lord Almighty " + me.name // composite string value with player name variable
"bool" indicates a Boolean (true/false) value. These are represented by 0 for false and 1 for true.
"object" indicates an object. Objects may have both properties (values) and methods (procedures/functions) attached to them. Objects can be yourself, other players, hirelings, NPCs, monsters, items, or stationary objects (chests, waypoints, etc.). Objects are also referred to as UNITs.
Functions and methods may require zero or more parameters (also known as "arguments") in order to work correctly. This guide outlines what sort of parameters must be passed to each function or method, in what order, and what each on represents. For example:
int rnd(int Low, int High)
This indicated that the rnd() function requires two parameters, both of which are integers.
Functions and methods also have return values, which can be of any data type depending on how the function is written. In this guide, a function's return value is indicated by the data type of the return value being placed before the model of the function, e.g.:
int rnd(int Low, int High)
This indicates that the rnd() function returns an integer value, which can be stored in a variable for later use, e.g.:
r = rnd(1, 100);
print("My random number between 1 and 100 is " + r + ".");
If a function or method is shown without a return value, this indicates that the function's return value is undefined, and should not be used in your program.
A more complete example:
object getPlayer(string PlayerName)
This declaration tells you several things:
The function's name is getPlayer(),
The getPlayer() function requires a player name string as its only argument, and
The getPlayer() function returns an object
Example:
mule = getPlayer("MyBootsMuleA");
print("MyBootsMuleA is located at " + mule.x + ", " + mule.y + ".");
--------------------------------------------------------------------------------
Functions
delay(int MilliSeconds)
Pauses script activity for the number of milliseconds specified.
Example:
delay(500); // pauses for a half-second
include(string LibraryScriptFileName)
Inserts the named script into the current script. The named script becomes a part of the current script's context, and can therefore share data and functions. Included scripts should not have a main() function, and must not have variable or function names which are the same as those in the current script.
Restrictions:
Included files should be named with a ".d2l" extension, as a matter of convention.
Example:
include("SyFindPath.d2l");
load(string ScriptFileName)
Loads and executes the specified d2jsp script in the d2jsp directory. Note that this command loads the script, begins executing it, and returns immediately. It does not wait for the script to finish executing, so this allows multiple scripts to run simultaneously. Scripts run in their own separate environments ("contexts," in the lingo), and cannot access each others' data or functions directly.
Example:
// Loads script to display player location coordinates on-screen
load("showlocation.d2j");
overhead(string OverheadText[, bool ShowEveryone])
Displays text over the player's head. The ShowEveryone parameter is optional, and defaults to FALSE.
Valid values for ShowEveryone are:
0: Display visible only on your screen, other players see nothing
1: Visible to all. Involves sending packets to the Battle.net server
Examples:
// display player position over head, client-side only
overhead("My Position is " + me.x + ", " + me.y + ".");
// place silly message overhead visible to other players
overhead("All your SOJ are belong to us!!!", 1);
print(String)
Displays the string "String" in the scrolling game messages window.
Example:
print("ÿc1Error!"); // prints "Error!" in red text
quit()
Immediately quits the current game. Equivalent to ESC-"Save & Exit".
raw(string D2HackitCommand)
Executes a D2Hackit! command.
Examples:
raw("pickit activate"); // turn on item pickup
raw("crash"); // Crashes client immediately
int rnd(int Low, int High)
Generates and returns a random integer number between Low and High.
Example:
goldAmountToDrop = rnd(1000, 65000); // chooses amount between 1,000 and 65,000
say(string ChatText)
Sends the chat message specified by ChatText to other players in the game.
Restrictions:
say("/w <whomever> whisper message"); does NOT whisper the message as intended.
Examples:
// announce yourself to the world
say("Hello, my name is " + me.name + ". Pleased to meet you! I am a d2jsp bot!");
sniffer(int RxTx, bool OnOff)
Produces D2 game packet dumps on screen. NOTE: this function is not turned off automatically when exiting a game, so you should issue sniffer(0, 0); sniffer(1, 0); on game exit in your script.
Parameters:
RxTx: 0: Received packets 1: Sent packets
OnOff: 0: Off 1: On
Example:
sniffer(1, 1); // display all packets D2 game sends to server
// [...]
// before script finishes
sniffer(1, 0);
sniffer(0, 0); // make sure we're not still sniffing next game
stop()
Terminates execution of the current script. Other scripts in memory continue to execute.
--------------------------------------------------------------------------------
UNIT Object creation commands
NOTE: In general, you will only need to create an object once per script. As the object's stats (such as position, life, etc) change during the game, the values returned by their properties will change as well.
object getCorpse(me.name) (deprecated)
As of beta 12, use getPlayer(me.name, 17) instead.
object getItem(string ItemName)
object getItem()
Returns the item object for the item specified by ItemName, or the first item unit in the game if ItemName is not specified.
Restrictions:
Valid only for item objects.
NEED examples
object getMissile(string MissileName)
object getMissile()
Returns the missile object for the missile specified by MissileName, or the first missile in the game's internal missile list if MissileName is not specified.
Restrictions:
Valid only for missiles.
NEED examples
object getNPC([string NPCName[, int Mode]])
Returns the NPC object for the NPC, hireling, or monster specified by NPCName, or the first NPC unit in the game if NPCName is not specified or is null. If the optional Mode parameter is specified, returns only NPCs in that Mode (see unit.mode, below).
Restrictions:
Valid for NPCs, hirelings, and monsters only. The optional NPCName must be the unique name of the monster, if the monster is a boss, or superunique, otherwise the monster class name will do. If the Mode is to be specified without the name, NPCName should be passed as "null".
Examples:
myAct2Merc = getNPC("Razan");
malah = getNPC("Malah");
pindle = getNPC("Pindleskin");
meph = getNPC("Mephisto");
// this returns the zombie listed first in D2's internal tables... unpredictable
zombie = getNPC("Zombie");
object getObject([string ObjectName[, int Mode]])
Returns the object (also known as "entity") object for the object specified by the optional ObjectName parameter, or the first object unit in the game if ObjectName is not specified. If the optional Mode parameter is specified, returns only objects in that Mode (see unit.mode, below).
Restrictions:
Only valid for fixed objects, such as the stash, chests, portals, seals, waypoints, and so forth. If the Mode is to be specified without a name, ObjectName should be passed as "null" (e.g., getObject(null, 1)).
Example:
// take red portal to Nihlathak's temple
portal = getObject("Portal");
portal.move();
portal.interact();
object getPlayer([string PlayerName[, int Mode]])
Returns the player object for the player specified by PlayerName, or the first player unit in the game if PlayerName is not specified. If the optional Mode parameter is specified, retrieves only player objects in the corresponding mode (for example, 17 for dead indicating a corpse).
Restrictions:
Valid only for OTHER players. Use the special object "me" for yourself. If the Mode is to be specified without a name, PlayerName should be passed as "null".
Example:
// kill this jerk if he shows up
enemy = getPlayer("SkeezorPK");
enemy.move();
me.setSkill("Frozen Orb", 0);
enemy.useSkill(0);
// show everyone in the game
player = getPlayer();
do {
if (player && player.name) {
print(player.name);
}
} while (player && player.getNext());
// pick up body
corpse = getPorpse(me.name, 17);
corpse.move();
corpse.interact();
object getRoom()
Returns the first room in the game's room list. Returns only rooms in the player's current area (level) as defined by me.area. Combine with room.getNext() to iterate through all rooms in the current area.
NOTE: the room.x and room.y properties of the room object are not scaled the same as other objects, and must be multiplied by five (5) to be comparable to other units' locations.
Restrictions:
Only valid for room objects.
NEED Examples
object getScreenHook()
Returns the screen object for use in displaying text on the game screen.
NEED Examples
object getTile()
Returns the first RoomTile object in the game. Useful for finding stairs and cave entrances, possibly other things.
Restrictions:
Valid only for RoomTile objects.
NEED Examples
--------------------------------------------------------------------------------
The "me" unit
There is a special UNIT called "me" which is always defined, and refers to YOUR character.
To access properties and methods of your character in a script, use the "me" unit rather than the typical unit = getPlayer("name"); unit.whatever(); technique.
Example:
say("Hello, my name is " + me.name + ". Pleased to meet you! I am a d2jsp bot!");
print("hello, my name is: " + me.name);
print("my class id is: "+ me.classid);
print("my position is: "+ me.x + "/" + me.y);
print("my life is: "+ me.hp + "/" + me.hpmax);
print("my mana is: " + me.mp + "/" + me.mpmax);
--------------------------------------------------------------------------------
UNIT methods
unit.cancel()
Cancels interaction with the unit. In the case of an item unit, drops the item.
Restrictions:
Only valid for NPCs (NEED: Also valid for stash? Hireling? Other players in trade?) You must be in interaction with the NPC in order to use this method. Items being dropped must be in hand (on the cursor/pointer).
NEED examples
npc.gamble()
Enters gamble dialog with an NPC.
Restrictions:
Valid for non-monster NPC who support gambling only. You must already be in interact() with the NPC.
Example:
gheed = getNPC("Gheed");
gheed.move();
gheed.interact();
gheed.gamble();
print("Now gambling with Gheed");
bool unit.getEnchants(int EnchantNumber)
Reports whether or not the unit has the enchantment specified by EnchantNumber. Returns TRUE if the enchantment is present. Note that monsters may have more than one enchantment (or none at all).
Restrictions:
Valid only for monster units.
Valid values for EnchantNumber:
Value Enchantment
0 Extra Strong
1 Extra Fast
2 Cursed
3 Magic Resistant
4 Fire Enchanted
5 Champion
6 Lightning Enchanted
7 Cold Enchanted
8 Thief (unimplemented)
9 Mana Burn
10 Teleportation
11 Spectral Hit
12 Stone Skin
13 Multiple Shots
14 Ghostly
15 Fanatic
16 Possessed
17 Berserker
Example:
pindleskin = getNPC("Pindleskin");
if (pindleskin.getEnchant(17))
print("Pindleskin is Lightning Enchanted");
object unit.getNext()
Returns the next object after the object, or false if there is no next object. Useful for iterating through the entire list of units of a given type.
NOTE: Units are stored in game memory in the order they are generated by the game, and are not sorted in any other way. Do not rely upon or expect the sequencing of units to be predictable. Use getObject(), getPlayer(), getNPC(), or getItem() to retrieve the first unit in the game's memory, and then iterate on the returned object through to the end.
NOTE: when iterating through a room list, only rooms in the current player area (level) as given by me.area are returned.
Example:
obj = getObject();
do {
if (obj) {
dprint("There's a " + obj.name + " at 0x" + obj.x.toString(16) + ", " + obj.y.toString(16));
}
} while (obj && obj.getNext());
object unit.getParent()
Returns the parent object of the object, or false if the object has no parent. Useful for determining who has possession of a given item.
NEED example
int unit.getStat(int StatNumber)
Returns the value of the unit's stat given by StatNumber. Returns false if the unit does not have the stat. Note that more than one stat may be present on a given unit. Stat values have varying ranges depending on what they represent. For example, a resistance stat may vary from -100 to +100, but the "Gold Bank" stat (how much gold you have in your stash) can vary from 0 to something around 3 million.
NOTE: Do no confuse unit STATS with unit STATES from the unit.getState() method. They are distinct.
Restrictions:
Valid only for player, monster, and item units.
Valid values for StatNumber:
Value State
0 STRENGTH
1 ENERGY
2 DEXTERITY
3 VITALITY
4 STATPTS
5 NEWSKILLS
6 HITPOINTS
7 MAXHP
8 MANA
9 MAXMANA
10 STAMINA
11 MAXSTAMINA
12 LEVEL
13 EXPERIENCE
14 GOLD
15 GOLDBANK
16 ITEM_ARMOR_PERCENT
17 ITEM_MAXDAMAGE_PERCENT
18 ITEM_MINDAMAGE_PERCENT
19 TOHIT
20 TOBLOCK
21 MINDAMAGE
22 MAXDAMAGE
23 SECONDARY_MINDAMAGE
24 SECONDARY_MAXDAMAGE
25 DAMAGEPERCENT
26 MANARECOVERY
27 MANARECOVERYBONUS
28 STAMINARECOVERYBONUS
29 LASTEXP
30 NEXTEXP
31 ARMORCLASS
32 ARMORCLASS_VS_MISSILE
33 ARMORCLASS_VS_HTH
34 NORMAL_DAMAGE_REDUCTION
35 MAGIC_DAMAGE_REDUCTION
36 DAMAGERESIST
37 MAGICRESIST
38 MAXMAGICRESIST
39 FIRERESIST
40 MAXFIRERESIST
41 LIGHTRESIST
42 MAXLIGHTRESIST
43 COLDRESIST
44 MAXCOLDRESIST
45 POISONRESIST
46 MAXPOISONRESIST
47 DAMAGEAURA
48 FIREMINDAM
49 FIREMAXDAM
50 LIGHTMINDAM
51 LIGHTMAXDAM
52 MAGICMINDAM
53 MAGICMAXDAM
54 COLDMINDAM
55 COLDMAXDAM
56 COLDLENGTH
57 POISONMINDAM
58 POISONMAXDAM
59 POISONLENGTH
60 LIFEDRAINMINDAM
61 LIFEDRAINMAXDAM
62 MANADRAINMINDAM
63 MANADRAINMAXDAM
64 STAMDRAINMINDAM
65 STAMDRAINMAXDAM
66 STUNLENGTH
67 VELOCITYPERCENT
68 ATTACKRATE
69 OTHER_ANIMRATE
70 QUANTITY
71 VALUE
72 DURABILITY
73 MAXDURABILITY
74 HPREGEN
75 ITEM_MAXDURABILITY_PERCENT
76 ITEM_MAXHP_PERCENT
77 ITEM_MAXMANA_PERCENT
78 ITEM_ATTACKERTAKESDAMAGE
79 ITEM_GOLDBONUS
80 ITEM_MAGICBONUS
81 ITEM_KNOCKBACK
82 ITEM_TIMEDURATION
83 ITEM_ADDAMASKILLPOINTS
84 ITEM_ADDPALSKILLPOINTS
85 ITEM_ADDNECSKILLPOINTS
86 ITEM_ADDSORSKILLPOINTS
87 ITEM_ADDBARSKILLPOINTS
88 ITEM_DOUBLEHERBDURATION
89 ITEM_LIGHTRADIUS
90 ITEM_LIGHTCOLOR
91 ITEM_REQ_PERCENT
92 ITEM_FASTATTACKRATE
93 ITEM_FASTERATTACKRATE
94 ITEM_FASTESTATTACKRATE
95 ITEM_FASTMOVEVELOCITY
96 ITEM_FASTERMOVEVELOCITY
97 ITEM_FASTESTMOVEVELOCITY
98 ITEM_FASTGETHITRATE
99 ITEM_FASTERGETHITRATE
100 ITEM_FASTESTGETHITRATE
101 ITEM_FASTBLOCKRATE
102 ITEM_FASTERBLOCKRATE
103 ITEM_FASTESTBLOCKRATE
104 ITEM_FASTCASTRATE
105 ITEM_FASTERCASTRATE
106 ITEM_FASTESTCASTRATE
107 ITEM_SINGLESKILL1
108 ITEM_SINGLESKILL2
109 ITEM_SINGLESKILL3
110 ITEM_POISONLENGTHRESIST
111 ITEM_NORMALDAMAGE
112 ITEM_HOWL
113 ITEM_STUPIDITY
114 ITEM_DAMAGETOMANA
115 ITEM_IGNORETARGETAC
116 ITEM_FRACTIONALTARGETAC
117 ITEM_PREVENTHEAL
118 ITEM_HALFFREEZEDURATION
119 ITEM_TOHIT_PERCENT
120 ITEM_DAMAGETARGETAC
121 ITEM_DEMONDAMAGE_PERCENT
122 ITEM_UNDEADDAMAGE_PERCENT
123 ITEM_DEMON_TOHIT
124 ITEM_UNDEAD_TOHIT
125 ITEM_THROWABLE
126 ITEM_FIRESKILL
127 ITEM_ALLSKILLS
128 ITEM_ATTACKERTAKESLIGHTDAMAGE
129 IRONMAIDEN_LEVEL
130 LIFETAP_LEVEL
131 THORNS_LEVEL
132 BONEARMOR
133 BONEARMORMAX
134 ITEM_FREEZE
135 ITEM_OPENWOUNDS
136 ITEM_CRUSHINGBLOW
137 ITEM_KICKDAMAGE
138 ITEM_MANAAFTERKILL
139 ITEM_HEALAFTERDEMONKILL
140 ITEM_EXTRABLOOD
141 ITEM_DEADLYSTRIKE
142 ITEM_ABSORBFIRE_PERCENT
143 ITEM_ABSORBFIRE
144 ITEM_ABSORBLIGHT_PERCENT
145 ITEM_ABSORBLIGHT
146 ITEM_ABSORBMAGIC_PERCENT
147 ITEM_ABSORBMAGIC
148 ITEM_ABSORBCOLD_PERCENT
149 ITEM_ABSORBCOLD
150 ITEM_SLOW
151 ITEM_BLESSEDAIM
152 ITEM_DEFIANCE
153 ITEM_CANNOTBEFROZEN
154 ITEM_STAMINADRAINPCT
155 ITEM_REANIMATE
156 ITEM_PIERCE
157 ITEM_MAGICARROW
158 ITEM_EXPLOSIVEARROW
159 ITEM_THROW_MINDAMAGE
160 ITEM_THROW_MAXDAMAGE
161 SKILL_HANDOFATHENA
162 SKILL_STAMINAPERCENT
163 SKILL_PASSIVE_STAMINAPERCENT
164 SKILL_CONCENTRATION
165 SKILL_ENCHANT
166 SKILL_PIERCE
167 SKILL_CONVICTION
168 SKILL_CHILLINGARMOR
169 SKILL_FRENZY
170 SKILL_DECREPIFY
171 SKILL_ARMOR_PERCENT
172 ALIGNMENT
173 TARGET0
174 TARGET1
175 GOLDLOST
176 CONVERSION_LEVEL
177 CONVERSION_MAXHP
178 UNIT_DOOVERLAY
179 ITEM_ADDDRUSKILLPOINTS
180 ITEM_ADDASSSKILLPOINTS
181 ITEM_ADDSKILL_SINGLE4
182 ITEM_ADDSKILL_SINGLE5
183 ITEM_ADDSKILL_SINGLE6
184 ITEM_ADDSKILL_SINGLE7
185 ITEM_ADDSKILL_SINGLE8
186 ITEM_ADDSKILL_SINGLE9
187 ITEM_ADDSKILL_SINGLE10
188 ITEM_ADDSKILL_TAB1
189 ITEM_ADDSKILL_TAB2
190 ITEM_ADDSKILL_TAB3
191 ITEM_ADDSKILL_TAB4
192 ITEM_ADDSKILL_TAB5
193 ITEM_ADDSKILL_TAB6
194 ITEM_NUMSOCKETS
195 ITEM_SKILLONATTACK1
196 ITEM_SKILLONATTACK2
197 ITEM_SKILLONATTACK3
198 ITEM_SKILLONHIT1
199 ITEM_SKILLONHIT2
200 ITEM_SKILLONHIT3
201 ITEM_SKILLONGETHIT1
202 ITEM_SKILLONGETHIT2
203 ITEM_SKILLONGETHIT3
204 ITEM_CHARGED_SKILL0
205 ITEM_CHARGED_SKILL1
206 ITEM_CHARGED_SKILL2
207 ITEM_CHARGED_SKILL3
208 ITEM_CHARGED_SKILL4
209 ITEM_CHARGED_SKILL5
210 ITEM_CHARGED_SKILL6
211 ITEM_CHARGED_SKILL7
212 ITEM_CHARGED_SKILL8
213 ITEM_CHARGED_SKILL9
214 ITEM_ARMOR_PERLEVEL
215 ITEM_ARMORPERCENT_PERLEVEL
216 ITEM_HP_PERLEVEL
217 ITEM_MANA_PERLEVEL
218 ITEM_MAXDAMAGE_PERLEVEL
219 ITEM_MAXDAMAGE_PERCENT_PERLEVEL
220 ITEM_STRENGTH_PERLEVEL
221 ITEM_DEXTERITY_PERLEVEL
222 ITEM_ENERGY_PERLEVEL
223 ITEM_VITALITY_PERLEVEL
224 ITEM_TOHIT_PERLEVEL
225 ITEM_TOHITPERCENT_PERLEVEL
226 ITEM_COLD_DAMAGEMAX_PERLEVEL
227 ITEM_FIRE_DAMAGEMAX_PERLEVEL
228 ITEM_LTNG_DAMAGEMAX_PERLEVEL
229 ITEM_POIS_DAMAGEMAX_PERLEVEL
230 ITEM_RESIST_COLD_PERLEVEL
231 ITEM_RESIST_FIRE_PERLEVEL
232 ITEM_RESIST_LTNG_PERLEVEL
233 ITEM_RESIST_POIS_PERLEVEL
234 ITEM_ABSORB_COLD_PERLEVEL
235 ITEM_ABSORB_FIRE_PERLEVEL
236 ITEM_ABSORB_LTNG_PERLEVEL
237 ITEM_ABSORB_POIS_PERLEVEL
238 ITEM_THORNS_PERLEVEL
239 ITEM_FIND_GOLD_PERLEVEL
240 ITEM_FIND_MAGIC_PERLEVEL
241 ITEM_REGENSTAMINA_PERLEVEL
242 ITEM_STAMINA_PERLEVEL
243 ITEM_DAMAGE_DEMON_PERLEVEL
244 ITEM_DAMAGE_UNDEAD_PERLEVEL
245 ITEM_TOHIT_DEMON_PERLEVEL
246 ITEM_TOHIT_UNDEAD_PERLEVEL
247 ITEM_CRUSHINGBLOW_PERLEVEL
248 ITEM_OPENWOUNDS_PERLEVEL
249 ITEM_KICK_DAMAGE_PERLEVEL
250 ITEM_DEADLYSTRIKE_PERLEVEL
251 ITEM_FIND_GEMS_PERLEVEL
252 ITEM_REPLENISH_DURABILITY
253 ITEM_REPLENISH_QUANTITY
254 ITEM_EXTRA_STACK
255 ITEM_FIND_ITEM
256 ITEM_SLASH_DAMAGE
257 ITEM_SLASH_DAMAGE_PERCENT
258 ITEM_CRUSH_DAMAGE
259 ITEM_CRUSH_DAMAGE_PERCENT
260 ITEM_THRUST_DAMAGE
261 ITEM_THRUST_DAMAGE_PERCENT
262 ITEM_ABSORB_SLASH
263 ITEM_ABSORB_CRUSH
264 ITEM_ABSORB_THRUST
265 ITEM_ABSORB_SLASH_PERCENT
266 ITEM_ABSORB_CRUSH_PERCENT
267 ITEM_ABSORB_THRUST_PERCENT
268 ITEM_ARMOR_BYTIME
269 ITEM_ARMORPERCENT_BYTIME
270 ITEM_HP_BYTIME
271 ITEM_MANA_BYTIME
272 ITEM_MAXDAMAGE_BYTIME
273 ITEM_MAXDAMAGE_PERCENT_BYTIME
274 ITEM_STRENGTH_BYTIME
275 ITEM_DEXTERITY_BYTIME
276 ITEM_ENERGY_BYTIME
277 ITEM_VITALITY_BYTIME
278 ITEM_TOHIT_BYTIME
279 ITEM_TOHITPERCENT_BYTIME
280 ITEM_COLD_DAMAGEMAX_BYTIME
281 ITEM_FIRE_DAMAGEMAX_BYTIME
282 ITEM_LTNG_DAMAGEMAX_BYTIME
283 ITEM_POIS_DAMAGEMAX_BYTIME
284 ITEM_RESIST_COLD_BYTIME
285 ITEM_RESIST_FIRE_BYTIME
286 ITEM_RESIST_LTNG_BYTIME
287 ITEM_RESIST_POIS_BYTIME
288 ITEM_ABSORB_COLD_BYTIME
289 ITEM_ABSORB_FIRE_BYTIME
290 ITEM_ABSORB_LTNG_BYTIME
291 ITEM_ABSORB_POIS_BYTIME
292 ITEM_FIND_GOLD_BYTIME
293 ITEM_FIND_MAGIC_BYTIME
294 ITEM_REGENSTAMINA_BYTIME
295 ITEM_STAMINA_BYTIME
296 ITEM_DAMAGE_DEMON_BYTIME
297 ITEM_DAMAGE_UNDEAD_BYTIME
298 ITEM_TOHIT_DEMON_BYTIME
299 ITEM_TOHIT_UNDEAD_BYTIME
300 ITEM_CRUSHINGBLOW_BYTIME
301 ITEM_OPENWOUNDS_BYTIME
302 ITEM_KICK_DAMAGE_BYTIME
303 ITEM_DEADLYSTRIKE_BYTIME
304 ITEM_FIND_GEMS_BYTIME
305 ITEM_PIERCE_COLD
306 ITEM_PIERCE_FIRE
307 ITEM_PIERCE_LTNG
308 ITEM_PIERCE_POIS
309 ITEM_DAMAGE_VS_MONSTER
310 ITEM_DAMAGE_PERCENT_VS_MONSTER
311 ITEM_TOHIT_VS_MONSTER
312 ITEM_TOHIT_PERCENT_VS_MONSTER
313 ITEM_AC_VS_MONSTER
314 ITEM_AC_PERCENT_VS_MONSTER
315 FIRELENGTH
316 BURNINGMIN
317 BURNINGMAX
318 PROGRESSIVE_DAMAGE
319 PROGRESSIVE_STEAL
320 PROGRESSIVE_OTHER
321 PROGRESSIVE_FIRE
322 PROGRESSIVE_COLD
323 PROGRESSIVE_LIGHTNING
324 ITEM_EXTRA_CHARGES
323 PROGRESSIVE_TOHIT
Example:
// detect and report on Pindleskin's immunities
var res_stat = [0x24, 0x25, 0x27, 0x29, 0x2b, 0x2d];
var res_name = ["Physical", "Magic", "Fire", "Lightning", "Cold", "Poison"];
immunities = "";
for (i = 0; i < 6; i++)
if (pindleskin.getStat(res_stat[i]) > 99)
immunities += res_name[i] + " Immune ";
if (immunities != "")
print("ÿc1Pindleskin is: ÿc4" + immunities);
bool unit.getState(int StateNumber)
Reports whether is in the state specified by StateNumber. Returns TRUE if the unit is in the specified state. Note that more than one state (or none at all) may be present on a given unit.
NOTE: Do no confuse unit STATES with unit STATS from the unit.getStat() method. They are distinct.
Restrictions:
Valid only for player and monster units.
Valid values for StateNumber:
Value State
0 None
1 Freeze
2 Poison
3 Resist Fire
4 Resist Cold
5 Resist Light
6 Resist Magic
7 Player Body
8 Resist All
9 Amplify Damage
10 Frozen Armor
11 Cold
12 Inferno
13 Blaze
14 Bone Armor
15 Concentrate
16 Enchant
17 Innersight
18 Skill Move
19 Weaken
20 Chilling Armor
21 Stunned
22 Spider Lay
23 Dim Vision
24 Slowed
25 Fetish Aura
26 Shout
27 Taunt
28 Conviction
29 Convicted
30 Energy Shield
31 Venom Claws
32 Battle Orders
33 Might
34 Prayer
35 Holy Fire
36 Thorns
37 Defiance
38 Thunder Storm
39 Lightning Bolt
40 Blessed Aim
41 Stamina
42 Concentration
43 Holy Wind
44 Holy Wind Cold
45 Cleansing
46 Holy Shock
47 Sanctuary
48 Meditation
49 Fanaticism
50 Redemption
51 Battle Command
52 Prevent Heal
53 Conversion
54 Uninterruptable
55 Iron Maiden
56 Terror
57 Attract
58 Lifetap
59 Confuse
60 Decrepify
61 Lower Resist
62 Open Wounds
63 Dopplezon
64 Critical Strike
65 Dodge
66 Avoid
67 Penetrate
68 Evade
69 Pierce
70 Warmth
71 Fire Mastery
72 Lightning Mastery
73 Cold Mastery
74 Sword Mastery
75 Axe Mastery
76 Mace Mastery
77 Polearm Mastery
78 Throwing Mastery
79 Spear Mastery
80 Increased Stamina
81 Iron Skin
82 Increased Speed
83 Natural Resistance
84 Finger Mage Curse
85 No Mana Regen
86 Just Hit
87 Slow Missiles
88 Shiver Armor
89 Battle Cry
90 Blue
91 Red
92 Death Delay
93 Valkyrie
94 Frenzy
95 Berserk
96 Revive
97 Item Full Set
98 Source Unit
99 Redeemed
100 Health Pot
101 Holy Shield
102 Just Portaled
103 Mon Frenzy
104 Corpse Nodraw
105 Alignment
106 Mana Pot
107 Shatter
108 Sync Warped
109 Conversion Save
110 Pregnant
111 111
112 Rabies
113 Defense Curse
114 Blood Mana
115 Burning
116 Dragon Flight
117 Maul
118 Corpse Noselect
119 Shadow Warrior
120 Feral Rage
121 Skill Delay
122 Progressive Damage
123 Progressive Steal
124 Progressive Other
125 Progressive Fire
126 Progressive Cold
127 Progressive Lightning
128 Shrine Armor
129 Shrine Combat
130 Shrine Resist Lightning
131 Shrine Resist Fire
132 Shrine Resist Cold
133 Shrine Resist Poison
134 Shrine Skill
135 Shrine Mana Regen
136 Shrine Stamina
137 Shrine Experience
138 Fenris Rage
139 Wolf
140 Bear
141 Bloodlust
142 Change Class
143 Attached
144 Hurricane
145 Armageddon
146 Invis
147 Barbs
148 Wolverine
149 Oak Sage
150 Vine Beast
151 Cyclone Armor
152 Claw Mastery
153 Cloak Of Shadows
154 Recycled
155 Weapon Block
156 Cloaked
157 Quickness
158 Blade Shield
159 Fade
Examples:
pindleskin = getNPC("Pindleskin");
if (pindleskin.getState(0x21))
print("Pindleskin has Might aura");
if (pindleskin.getState(0x1c))
print("Pindleskin has Conviction aura");
while (pindleskin.hp > 0) {
me.useSkillAt(pindleskin.x, pindleskin.y, right_hand);
delay(100);
// We're going to wait here until the timer for the skill we just used expires
while (me.getState(121))
delay(50);
}
unit.interact()
Interacts with the unit. Using unit.move() before unit.interact() is recommended, since this is equivalent to clicking on the unit. Also useful for taking waypoints, fixed portals, and town portals. (NEED: would interact() on another player ask to trade?? With merc to open merc inventory?)
Restrictions:
Only valid for NPCs, Objects, and player corpse. You must be nearby the unit in order to use this method.
Examples:
malah = getNPC("Malah");
malah.move(); // move to Malah
malah.interact(); // Heal me... touch me...
malah.cancel(); // leave Malah
// [...] Cruise over near Anya [...]
portal = getObject("Portal"); // Anya's portal
portal.move();
portal.interact(); // warp to Pindle-land
item.interact([bool Parameter])
Grabs, buys, or uses an item, according to this table:
Item Location Parameter unset Parameter = 1
Inventory (including stash/cube/merc) Pick up to cursor Use item from location
Ground Pick up to inventory Pick up to cursor
Store Purchase Shift-right-click purchase (fill up)
Restrictions:
Valid for items only.
NEED examples
unit.move()
me.move(int x, int y)
Valid for any non-player object in the case of unit.move(), and for the player object "me" only in the case of unit.move(x, y). For monsters, moving to them is optional, and dependent on the specific needs of the scripts and the character. NOTE: You must be within a reasonable range and have an unobstructed path to the destination, as there is no automatic path finding for the player during these moves.
Examples:
// Do a silly dance for a while
i = 0;
while (i++ < 100) {
me.move(me.x + 5 * ((i % 2) * 2 - 1), me.y + 5 * ((i % 2) * 2 - 1));
delay(250);
}
// Walk to the stash
stashX = 0x1416; stashY = 0x13c0;
me.move(stashX, stashY);
// It's a good idea to .move() to a unit before trying to .interact() with it
charsi = getNPC("Charsi");
charsi.move(); // move to Charsi
charsi.interact(); // sweet lovin'
// not a smart move
bigD = getNPC("Diablo");
bigD.move(); // I'm either really strong, or suicidal
item.move(int x, int y, int StorageLocation)
Moves an item currently in the hand to the storage location specified. x and y are based from 0, 0 at the top-left corner of the storage container.
NOTE: Moving an item on top of another item will cause disconnection, and may corrupt your characters.
Restrictions:
Valid only for item objects. Item must be in hand.
Values for the StorageLocation parameter:
0: Player inventory
3: Cube
4: Stash
NEED Examples
item.move(int BodyLocation)
Equip an item.
NOTE: Moving an item on top of another item will cause disconnection, and may corrupt your characters.
Restrictions:
Valid only for item objects. Item must be in hand.
NEED Examples
npc.repair()
Ask NPC to repair all of your damaged equipment.
Restrictions:
Only valid with NPCs who can repair equipment. You must be in interaction with the NPC in order to use this method.
Example:
larzuk = getNPC("Larzuk");
larzuk.move(); // move to Larzuk
larzuk.interact(); // talk to Larzuk
larzuk.repair(); // get gear fixed up
larzuk.cancel(); // say bye-bye to Larzuk
npc.revive()
Revive your hireling (mercenary).
Restrictions:
Only valid with NPCs who can revive hirelings. You must be in interaction with the NPC in order to use this method.
Example:
asheara = getNPC("Asheara");
asheara.move(); // move to Asheara
asheara.interact(); // talk to Asheara
asheara.revive(); // resurrect merc
asheara.cancel(); // later, Ashy
me.setSkill(string SkillName, int Hand)
Selects a skill. The SkillName parameter must be a correctly-spelled version of the skill name ("Static Field", for example), but capitalization is not important ("sTaTic FIELD" works just as well). The Hand parameter should be set to 0 for the right hand, or 1 for the left hand.
NOTE: Due to a last-minute programming change in D2, the Amazon skill you know as "Decoy" is referred to internally as "Dopplezon", and must be specified as such for it to work.
Restrictions:
Valid only for the player object ("me").
Examples:
me.setSkill("Frozen Orb", 1); // Frozen Orb on left hand skill
me.setSkill("teleport", 0); // Teleport on right-click
// test to make sure we actually have the skill
if (me.setSkill("Dopplezon", right_hand)) { // "Decoy" is "Dopplezon" internally
me.useSkill(right_hand);
} else {
print("failed to set skill to Decoy");
}
unit.trade()
Enter trade with the unit.
Restrictions:
Valid only for NPCs and players (NEED: Verify players).
NEED Examples
unit.use([bool OnHireling])
DEPRECATED: use item.interact()
Use a potion or scroll from the player's belt. Valid only for item objects. If the optional OnHireling parameter is true (1), the potion will be fed to the player's hireling.
Restrictions:
Valid for the player object ("me").
NEED examples
unit.useSkill(int Hand)
Causes the player to cast a selected skill on the unit.
Restrictions:
Valid for the player object ("me"), monsters, hirelings, corpses, and objects. You must be within range of the unit, and the unit must be within range of the skill, in order to use this method.
Values for the Hand parameter:
0: Right hand
1: Left hand
Examples:
// Cast untargeted omnidirectional attack spell
me.setSkill("Nova", 0);
me.useSkill(0);
// Enchant your merc
me.setSkill("Enchant", 0);
merc = getNPC("Razan"); // Blossom's Act 2 NM merc
merc.useSkill(0);
// Buff up
me.setSkill("Battle Orders", 0);
me.useSkill(0);
// [...] Move to Pindleskin [...]
pindle = getNPC("Pindleskin");
me.setSkill("Whirlwind", 1);
pindle.move(); // Run to Pindle
while (pindle.hp) {
pindle.useSkill(1); // Kill that pesky skeleton creep!
while (me.state >=7 && me.state <= 16) {
delay(20); // 20ms, roughly half a frame
}
}
// Pindleskin has died (yet again)...
me.setSkill("Find Item", 0);
pindle.useSkill(0); // Loot the poor bastard's corpse
me.useSkillAt(int x, int y, int Hand)
Causes the player to cast a selected skill at a location. This is useful for skills that can be cast on an area rather than a unit. You must be within range of this location, and the location must be in range of the skill, to use this method. x and y may be expressed in decimal or hexadecimal (with the "0x" prefix) notation. Only valid for the player object ("me"). The Hand parameter should be set to 0 for the right hand, or 1 for the left hand.
Restrictions:
Valid only for the player unit "me".
Examples:
// Teleport (probably a good way to get killed)
me.setSkill("Teleport", 0);
me.useSkillAt(getNPC("Lister the Tormenter").x, getNPC("Lister the Tormenter").y, 0);
// Multiple shots
me.setSkill("Multiple Shots", 1);
me.useSkillAt(me.x + 10, me.y, 1); // fire up and to the right
me.weaponSwitch()
Swaps weapons between slots I and II.
Restrictions:
Valid only for the player unit "me".
NEED: Example
--------------------------------------------------------------------------------
UNIT Properties
int unit.act
The act in which the unit is located.
Restrictions:
Really only useful for the player ("me") object, but may also be used to detect which act another player is in.
Settable? No
Values:
1: Act 1
2: Act 2
3: Act 3
4: Act 4
5: Act 5
Example:
act = me.act; // find out what act we're in
if (act != 3) { // um... Mephisto is in Act 3...
print("Not started in Act 3. Correcting...");
raw("load fastwp");
raw("fastwp 3 1"); // use Gayak's fastwp module to warp to Kurast Docks
raw("unload fastwp");
}
int unit.area
The game area in which the unit is located. "Area" corresponds internally to the game's "level".
Settable: No
Examples:
if (me.area == 1) {
print("I am in the Rogue Encampment");
}
if (me.area == 75) {
print("I am at the Kurast Docks");
}
bool me.autoloot
Determines if the "allow loot" flag will be set on player death or not.
Restrictions:
Only valid and settable for the player object "me", and useful only for Hardcore play.
Default: False
Settable: Yes
NEED: example
bool me.autoparty
Determines whether or not party invitations from other players will be accepted automatically.
Restrictions:
Only valid and settable for the player object "me".
Default: False
Settable: Yes
bool me.autoquitonpk
Determines whether or not to immediately exit the current game if another player declares hostility for the character.
Restrictions:
Only valid and settable for the player object "me".
Default: False
Settable: Yes
bool unit.busy
Flag telling whether or not the unit is currently busy.
Settable: No
int me.chickenhp
Life level at which to chicken out of the game automatically, via the same method as quit(). Note that this value is global, meaning that setting it in one script affects the value in all other scripts running at the same time. This value is reset to 0 at game start, which disables chickening.
Restrictions:
Only valid and settable for the player object "me".
Default: 0
Settable? Yes
int me.chickenmp
Mana level at which to chicken out of the game automatically, via the same method as quit(). Note that this value is global, meaning that setting it in one script affects the value in all other scripts running at the same time. This value is reset to 0 at game start, which disables chickening.
Restrictions:
Only valid and settable for the player object "me".
Default: 0
Settable? Yes
int unit.classid
Numeric class ID of the unit.
Restrictions:
This property is valid only for player units. (NEED: check into this more)
Settable? No
Class IDs are:
0: Amazon
1: Sorceress
2: Necromancer
3: Paladin
4: Barbarian
5: Druid
6: Assassin
Example:
class = me.classid; // fetch this player's class
if (class != 1) { // uh-oh, not a sorceress
print("Sorry, this script is only usable by a Sorceress, because it uses the Teleport skill");
stop();
}
string unit.code
The three-letter item code of the item.
Restrictions:
Valid only for items.
Settable: No
NEED: Examples
int unit.hp
The current Life of the unit. Currently, monster.hp is equal to the monster's current Life divided by its maximum life (NOT monster.hpmax, which is always 0x80), divided by 0x80.
Restrictions:
Valid only for players, monsters, and hirelings.
Settable? No
int unit.hpmax
The maximum Life of the unit. Currently, all monsters have an hpmax of 128 (0x80).
Restrictions:
Only valid for players and monsters
Settable? No
int unit.id
Numeric ID of the unit. Objects, Items, Players, and NPCs (NPC, players, hirelings, and monsters) are all given unique identifying numbers when they are instantiated (created) in the game. These numbers change from game to game, and even from moment to moment, depending on what is going on. This property is generally not needed by basic scripts.
Restrictions:
Not valid for Room objects.
Settable? No
int item.itemloc
The location of the item.
Restrictions:
Valid only for item objects. NOTE: This property is incompletely implemented at this time (NEED).
Settable: No
Values of item.itemloc:
Value Player In Store
0 In inventory Armor tab
1 Weapons tab 1
2 Weapons tab 2
3 In stash Misc tab
4 In cube
5
6
7
8
9
10
int item.itemtype
Generic type of the time.
Restrictions:
Valid only for item objects.
Values of item.itemtype:
0: Shield
1: Armor
2: Gold
3: Bow Quiver
4: Crossbow Quiver
5: Player Body Part
6: Herb
7: Potion
8: Ring
9: Elixir
10: Amulet
11: Charm
12: Not Used
13: Boots
14: Gloves
15: Not Used
16: Book
17: Belt
18: Gem
19: Torch
20: Scroll
21: Not Used
22: Scepter
23: Wand
24: Staff
25: Bow
26: Axe
27: Club
28: Sword
29: Hammer
30: Knife
31: Spear
32: Polearm
33: Crossbow
34: Mace
35: Helm
36: Missile Potion
37: Quest
38: Body Part
39: Key
40: Throwing Knife
41: Throwing Axe
42: Javelin
43: Weapon
44: Melee Weapon
45: Missile Weapon
46: Thrown Weapon
47: Combo Weapon
48: Any Armor
49: Any Shield
50: Miscellaneous
51: Socket Filler
52: Second Hand
53: Staves And Rods
54: Missile
55: Blunt
56: Expansion
57: Jewel
58: Class Specific
59: Amazon Item
60: Barbarian Item
61: Necromancer Item
62: Paladin Item
63: Sorceress Item
64: Assassin Item
65: Druid Item
66: Hand to Hand
67: Orb
68: Voodoo Heads
69: Auric Shields
70: Primal Helm
71: Pelt
72: Cloak
73: Rune
74: Circlet
75: Healing Potion
76: Mana Potion
77: Rejuv Potion
78: Stamina Potion
79: Antidote Potion
80: Thawing Potion
81: Small Charm
82: Medium Charm
83: Large Charm
84: Amazon Bow
85: Amazon Spear
86: Amazon Javelin
87: Hand to Hand 2
88: Magic Bow Quiv
89: Magic Xbow Quiv
Settable: No
NEED examples
int unit.mp
The current Mana of the unit.
Restrictions:
Valid only for players.
Settable? No
int unit.mpmax
The maximum Mana of the unit.
Restrictions:
Only valid for the player object "me".
Settable? No
string unit.name
The name of the unit. In the case of items, represents the unadorned name of the item, without mods or unique/set/rare designations (simply "Mesh Armor" for Shaftstop, for instance).
Note that in the case of monsters, monster.name will be the full proper name of the monster, not just its base name. Therefore, if you do this:
snapchip = getNPC("Snapchip Shatter");
print("snapchip.name = " + snapchip.name);
Your output will be "Snapchip Shatter" and NOT "Frozen Creeper", which is Snapchip's base name. The same holds for any unique, super-unique, or boss monster in the game. (NEED: What about champions/ghostlies/fanatics/possesseds?)
Restrictions:
Not valid for Room objects (NEED: fix this!)
Settable? No
int room.number
Room number of the room as defined in the Diablo II MPQ data files.
Restrictions:
Valid only for room objects.
NEED Examples
int item.quality
The item's quality. Useful only for item objects.
Values of unit.quality:
1: Low Quality
2: Normal
3: Superior
4: Magic
5: Set
6: Rare
7: Unique
8: Crafted
Settable: No
NEED examples
bool me.randommove
Flag indicating whether calls to the unit.move() method for the player will use randomization.
Restrictions:
Only valid and settable for the player object "me".
Default: True
Settable: Yes
int unit.mode
int unit.state (deprecated)
The current mode of the unit. Useful for determining if you're still walking, casting a spell, etc.
Restrictions:
Only valid for player, NPCs/monsters/hirelings, items, and objects.
Settable? No
unit.mode values:
Value Player NPC/Monster/Hireling Object Item
0 Death Death Idle Invetory/Stash/Cube/Store
1 Standing still outside town Standing still Operating Equipped on self or hireling
2 Walking Walking Opened In belt
3 Running Getting hit Special 1 On ground
4 Getting hit Attacking (Attack 1) Special 2 In hand (Cursor)
5 Standing still in town Attacking (Attack 2) Special 3 Being dropped
6 Walking in town Blocking Special 4 Socketed in another item
7 Attacking (Attack 1) Casting spell/skill Special 5
8 Attacking (Attack 2) Using Skill 1
9 Blocking Using Skill 2
10 Casting a spell/skill Using Skill 3
11 Throwing an item Using Skill 4
12 Kicking Dead
13 Using Skill 1 Being knocked back
14 Using Skill 2 Sequence (???)
15 Using Skill 3 Running
16 Using Skill 4 n/a
17 Dead n/a
18 Sequence (???) n/a
19 Being knocked back n/a
100 In Inventory
101 In store
103 In cube
104 In stash
Example:
me.setSkill("Energy Shield", 0);
me.useSkill(0);
// now, wait until we're actually ready to cast the next spell
while (me.state == 10) { // Casting a spell
delay(20); // wait half a frame (20 ms) before rechecking
}
me.setSkill("Shiver Armor", 0);
me.useSkill(0);
int unit.type
The unit's type.
Restrictions:
Not valid for Room objects.
Values:
0: Player
1: Monster
2: Object
3: Missile
4: Item
5: Room Tile
Settable: No
NEED examples
int unit.x
int unit.y
X and Y coordinates of the unit. In the case of items, represents the X, Y coordinates inside the stash, inventory, cube, or trade buffer, based at 0, 0.
NOTE: the unit.x/y properties on Room objects are scaled differently than general world coordinates. Multiply these values by five (5) to arrive at the corresponding world coordinates.
Settable? No
Example:
malah = getNPC("Malah");
print("Malah located at x=" + malah.x + ", y=" + malah.y + ".");
--------------------------------------------------------------------------------
File manipulation
FILE object creation function
object fileOpen(string FilePathName, int Mode)
Opens a file for reading, writing, or appending. Returns a FILE object if successful, otherwise returns false.
Valid values of Mode:
0: Read
1: Write
2: Append
FILE object methods
file.close()
Closes the file and destroys the object. (NEED: is this true?)
string file.readLine()
Returns a string containing the next line in the file. The last characters of the string will be CR and LF.
Restrictions:
Lines longer than 1023 characters are not supported, and will be truncated after the 1023rd character.
bool file.seek(int Offset, int Origin)
Sets the current file position specified in Offset, relative to the specified in Origin. Clears the end-of-file indicator file.eof.
Restrictions:
Undefined behavior results from seeking on unopened files.
Valid values for Origin:
0: Beginning of file
1: Current file position
2: End of file
NEED Examples
bool file.writeLine(string Text)
Writes the string Text, plus a terminating CRLF sequence, to the file. Returns true if successful, false otherwise.
FILE properties
bool file.eof
Is true if the file pointer in the file is currently at the end of file, and false otherwise.
Composite Example:
file = fileOpen("test_output.txt", 1); // open file for write (0=read, 1=write, 2=append)
if(!file) {
print("failed to open file for writing");
} else {
file.writeLine("hello mr. file io!");
file.writeLine("you are my FRIEND");
file.close();
}
file = fileOpen("test_output.txt", 0); // open file for write (0=read, 1=write, 2=append)
if(!file) {
print("failed to open file for reading");
} else {
while(!file.eof)
print(file.readLine());
file.close();
}
int file.pos
The current position in bytes from the start of the file. Undefined if the file is not currently open. UNIMPLEMENTED (NEED)
NEED example
--------------------------------------------------------------------------------
Diablo, Diablo II, Diablo II: Lord of Destruction, and Battle.net are registered trademarks of Blizzard Entertainment.
--------------------------------------------------------------------------------
Copyright (c) 2002 by Mike Gogulski and the d2jsp project. All rights reserved.