Script Not Doing Anything

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
mikel123
UOX3 Neophyte
Posts: 27
Joined: Thu Aug 18, 2011 4:28 pm
Has thanked: 0
Been thanked: 0

Script Not Doing Anything

Post by mikel123 »

I'm brand new to this javascripting business.

I have a file called magic_weapon.dfn which includes:

Code: Select all

[accurateaxe]
{
get=0x0f49
//name=a magic axe
name=an accurate axe
value=60 30
lodamage=6
hidamage=33
hp=31 100
race=
script=6005
}
[accuratekryss]
{
get=0x1401
//name=a magic kryss
name=an accurate kryss
value=54 27
lodamage=3
hidamage=28
hp=31 90
race=
script=6005
}
I have a file in my custom js folder called accurate.js, which contains:

Code: Select all

//Mike's Script for Magic Items of Accuracy

function onEquip(mChar, ourObj) 
{ 
 if (mChar.online == true) 
 { 
 if (ourObj.id == accurateaxe || ourObj.id == accuratekryss) 
 {mChar.skills.tactics = (mChar.skills.tactics + 50);} 
}
}

function onUnequip(mChar, ourObj) 
{ 
 if (ourObj.id == accurateaxe || ourObj.id == accuratekryss) 
 {mChar.skills.tactics = (mChar.skills.tactics - 50);} 
} 

I have a file called jse_fileassociations.txt, which contains:

Code: Select all

...
5017=item/spyglass.js
5018=item/magicscroll.js
5019=item/bola.js
6005=custom/accurate.js
}
What am I missing? When my GM does:

'add item accuratekryss

...the item is created as expected. But when he hands it to my player character, and the player character equips it, nothing happens. No tactics gain, no error message in UOX3, nothing.

Any ideas?

EDIT: I solved the problem. It seems I was referencing the name of the item in brackets, for example accuratekryss, as the ourObj.id. I thought the bracketed name was the id of the item, but apparently it is literally the id= field.

This tuns out to not be a problem, since I can have a normal kryss of id=0x1401 and an accurate kryss with id=0x1401, and only the accurate kryss will get the tactics bonus because only it will have the "script=6005" as a line in its item info.
Post Reply