Stranf's First Magic Items v .1

Got any custom JavaScript additions/tweaks you think other people would like to see? Post 'em here!
Post Reply
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Stranf's First Magic Items v .1

Post by stranf »

Well, since tommorow is the start of homework for the upcoming week, I'll post what i've done so far and add a new script for upcoming items.

Copy this script and save it to a *.dfn file. I saved mine in the dfndata/items/gear/armor, under the title tbs_magic1.

**Version .1 notes**
--tested all but ring of command.
--item identification works through my loremaster as scripted. (most hard-coded objects when identified the first time the master says funky things, afterwords it's cleared up for additional identifies)

--more to follow! Any item requests (not too complicated ones) feel free to chip in. I'll probably start with lesser, more common, magic items before testing my hand at uber ones.

//Magic gauntlets

[m_gloves]
{ left facing
get=leather_gloves
name2=Leather Gloves of Minor Strength
name=Leather Gloves
id=0x13c6
script=5020
def=1
value = 650, 200
}

[m_studgloves]
{ right Facing
get=studded_gloves
name=studded gloves
name2=studded gloves of minor strength
id=0x13dd
def=1
script=5020
value= 750,250
}


[m_ringgloves]
{
get=ring_gloves
name=ringmail gloves
name2=ringmail gloves of minor strength
id=0x13eb
def=2
script=5020
value=1000, 400
}

[m_plategloves]
{ left facing
get=plate_gloves
name=platemail gloves
name2=platemail gloves of minor strength
id=0x1414
def=2
script=5020
value=1200,500
}

//Magic boots
[boots_wander]
{
get=base_item
name=boots
name2=boots of wandering
id=0x170b
weight=300
value=790,22
layer=0x03
def=1
hp=30
str=10
dyeable=1
decay=1
script=5020
}

[sandals_wander]
{
get=base_item
name=sandals
name2=sandals of wandering
id=0x170d
weight=100
value=650,75
layer=0x03
hp=10
dyeable=1
decay=1
script=5020
}

[shoes_wander]
{
get=base_item
name=shoes
name=shoes of wandering
id=0x170f
weight=200
value=675,80
layer=0x03
hp=20
dyeable=1
decay=1
script=5020
}

[tboots_wander]
{
get=base_item
name=thigh boots
name2=thigh boots of wandering
id=0x1711
weight=400
value=750,95
layer=0x03
def=2
hp=50
str=20
dyeable=1
decay=1
script=5020
}

[shadow_cloak]
{
get=base_item
name=cloak
name2=shadow cloak
id=0x1515
weight=500
value=985,21
layer=0x14
hp=50
restock=10
dyeable=1
decay=1
script = 5020
}


[ring_command]
{
get=base_item
name=ring
name2=ring of commanding
id=0x108a
weight=100
value=790,13
restock=10
decay=1
script = 5020
}
[/quote]
Last edited by stranf on Sun Jan 29, 2006 8:14 am, edited 1 time in total.
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

STEP 2: Here is the script file. copy and place in your custom script directory. I chose the name magici1.js
//Script for magic items 1
//by Stranf
//Last edited 2/24/06

//Script for magic items 1
//by Stranf
//Last edited 2/20/06

function onEquip(mChar, ourObj)
{
 if (mChar.online == true)
 {
 if (ourObj.id == 0x13c6 || ourObj.id == 0x1414 ||ourObj.id == 0x13eb || ourObj.id ==0x13dd)
 {mChar.tempstr=(mChar.tempstr + 1);}  //script used for gloves of minor strength

 if (ourObj.id ==  0x170b||ourObj.id == 0x170d ||ourObj.id ==0x170f ||ourObj.id == 0x1711) //scipt used for footwear of wandering.
 {mChar.tempdex=(mChar.tempdex + 1);}

 if (ourObj.id ==0x1515) //script for shadow cloak
 {mChar.skills.hiding = (mChar.skills.hiding + 150);
  mChar.skills.tactics = (mChar.tactics - 200);
  mChar.skills.archery = (mChar.archery -200);
  mChar.skills.stealth = (mChar.skills.stealth +150);
  mChar.tempdex=(mChar.tempdex +3);}

 if (ourObj.id == 0x108a) //script for ring of commanding
     {mChar.skills.tactics = (mChar.skills.tactics + 100);
      mChar.fame = (mChar.fame + 100);}

}
}



//unequip here.
function onUnequip(mChar, ourObj)
{
   if (ourObj.id == 0x13c6 ||ourObj.id == 0x1414 ||ourObj.id == 0x13eb ||ourObj.id == 0x13dd)
    {mChar.tempstr=(mChar.tempstr - 1);}
   if (ourObj.id == 0x170b ||ourObj.id == 0x170d ||ourObj.id ==0x170f ||ourObj.id == 0x1711)
     {mChar.tempdex=(mChar.tempdex - 1);}
   
 if ((ourObj.id ==0x1515)) //script for shadow cloak
 {mChar.skills.hiding = (mChar.skills.hiding - 150);
  mChar.skills.tactics = (mChar.skills.tactics + 200);
  mChar.skills.archery = (mChar.skills.archery +200);
  mChar.skills.stealth = (mChar.skills.stealth - 150);
  mChar.tempdex=(mChar.tempdex -3);}

 
 if (ourObj.id == 0x108a) //script for ring of commanding
     {mChar.skills.tactics = (mChar.skills.tactics - 100);
      mChar.fame = (mChar.fame - 100);}
}


notice the DFN is pre-set to script 5020. If it's available just link there and you won't have any problems or editing. For more information on linking scripts to js, please view the in-detail steps in my loremaster post.

http://uox3.org/forum/viewtopic.php?t=763
Last edited by stranf on Sat Feb 25, 2006 5:31 am, edited 2 times in total.
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

STEP 3
To add the items to the world, login with GM privlegaes and type:

Code: Select all

'add item ring_command
follow the targeting prompt and your information will be saved.

Here is the item list and commands to put them in the world:

Code: Select all

ADD ID		Item Name	

Gauntlets	All gauntlest are of minor strength and add 1 point strength to the wearer.

m_gloves	Leather Gloves of Minor Strength
m_studgloves	Sudded Gloves of Minor Strength
m_ringgloves	Ringmail Gloves of Minor Strength
m_plategloves	platemail Gloves of Minor Strength

Footwear	All magic footwear adds 1 to dexterity

boots_wander	Boots of wandering
sandals_wander	sandals of wandering
shoes_wander	shoes of wandering
tboots_wander	thigh boots of wandering

Special Items	These items are unique

shadow_cloak	Should increase hiding/stealth while lowering tactics and archery but for some reason won't.  It will, increase dex by 3.

ring_command	Should increase tactics and fame of the wearer.  Untested, but I'm sure the tactics part won't work (see shadow_cloak)
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

note to Js masters:

if you can find out why my skills won't increase/decrease please inform and I will correct it fast.


QUESTION 2

in order for me to check IDs of the item, I have to use the ourObj.id, which refers to id in .dfn file. I assume the id-hex also contains the code for the objects properties and graphics.

so if I were to create leather gloves of greater strength (which used the same base id hex of 0x13c6, how would I distinguish it in the onEquip function from the gloves of minor strength?

Is there anyway to use my unique [m_studgloves] while in js?

example: if ourObj.tag = "m_studgloves"

If there is another way without using the ".id" I should be able to create more items in one script. As I've scripted it now, I can only have 1 ring per .js script. :cry:

QUESTION 3

the value tag? is the first number base buy, while second is base sell? Or is it a range for both? I kept the big number bigger, and the small one fairly small. My goal is to make these objects expensive to buy (either through quests only or GM controled player vendors) and sell to NPCs (if they'll take them) low. I don't want UO to turn into D&D where you are dirt poor until you start selling those +1 sling bullets to become uber-rich!!


Any other questions/comments/code tips are welcome.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post by giwo »

Try using mChar.skills.skillName

IE

character.skills.hiding
Scott
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

I tried that orginally, and it returned a complier error. I can't remember what it didn't like, but as soon as I erased the "skills" portion it complied nicely. I'll test some more and try again.

On second thought, I might have had a few that were misspelled to:

Code: Select all

mChar.skill.hiding
that would throw my compiler off. Hmm. If I get a break between school I'll test some more.[/code]
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

I don't think the DFN headers are saved in the .wsc files. Perhaps they should be. But a different way of doing this, would be to setup your DFN scripts with custom tags, or one specific custom tag with varying values for each item - then check against that tag in the JS script instead of against id.

The main problem with that "solution", is of course that there does not yet exist a way of assigning custom tags to DFN files as far as I know - though we should definitely do something about that :P
-= Ho Eyo He Hum =-
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

NOTE:

There are errors in the magic1.js. If you tried it out, you may have noticed. At home I have the corrections and will post ASAP.


Xuri: Yeah, currently I'm just going to distinquish items by the item id tag. It's not too bad, you just might have to add a few scripts to your jse_associations.

My magic2 will be up shortly. What's nice, is that your item.ids are already coded, so you just have to make minor changes to the dfn and the script and you have variants. My magic2 currently has new gloves, boots, cloak, ring, swords, axes, staff-like polearms.

As soon as I add bladed polearms, maces, and bows I'll release magic2. (It should be here mid week, depending on my homework load....darn engineering classess!)
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Just updated the script file. Please download and replace
--Changed the attribute gains from raw values to temp values. hopefully this clears up some issues.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

Stranf,

I didn't advertise this, though I probably should have. I made a first (testing only! backup config files!) test release of the PkgInstaller program ( http://sourceforge.net/project/showfile ... _id=113893 Files list there). Read the documentation closely, back things up, and give it a go. Grab the release (you don't want the source), because it has an example way to package up a release in there (it uses your early example of this magic weapons stuff). Let me know what you think, and if there's anything else you need, it's something I'll be working on over time.
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Well Maarc, sounds like a plan. I'm running out of time tonight, and my dialup can't connect to sourceforge.net.

i'll take a look at it later this week.

Thanks.
Maarc
Developer
Posts: 576
Joined: Sat Mar 27, 2004 6:22 am
Location: Fleet, UK
Has thanked: 0
Been thanked: 0
Contact:

Post by Maarc »

No problems, people will test it when they can, I realise that :)
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Maarc,

Just got a copy of your package installer

I'm going to try and add 2 or 3 more item scripts (each bigger than before) and package all of my scripts into your installer. So we'll see how it works!
Lok1728
UOX3 Newbie
Posts: 14
Joined: Fri Feb 03, 2006 2:54 am
Has thanked: 0
Been thanked: 0

Post by Lok1728 »

I just implemented this magic items v.1 and the items work up until one has the loremaster identify it. The loremaster says "eh, just a regular pair of boots" for example and now the magic item is not longer magic but just plain clothing.

Any ideas?
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Really? Which boots were they?

The problem could be resulting from the naming. The loremaster script swaps names of the objects, but does not change the attached scripts. The loremaster could say, "Those boots are smelly and worthless", but it still should add the dexterity bonus (or tracking depending on which boots you are id-ing.)

Double check and see if it is indeed not adding and subtracting (on takeoff) the scripted values.

I'll check it this weekend when midterms are over as well.
Lok1728
UOX3 Newbie
Posts: 14
Joined: Fri Feb 03, 2006 2:54 am
Has thanked: 0
Been thanked: 0

Post by Lok1728 »

Hey Stranf, thanks for the reply. I checked it again this morning after waking up and indeed the items keep their value. However, the name is changed to "thigh boots" for example rather than "Thigh Boots of Wandering" but the loremaster never even tells you they are magical boots.

So, a pc will just think they are shnormal boots / item and either toss them unless they actually look at their stats change when putting on the item. I've done this with most items in testing them and the loremaster just says their regular items and changes the name in the NAME2 field. But they do keep their values. You just don't know it's a magical item unless you're a GM and can check stats of an item. (or you see a change when wearing the item.)

I check the stats before ID'ing them with the loremaster and after. It seems that the NAME2 (once ID'd) would replace NAME1 so you know what the item is. Instead of Thigh Boots, after ID'ing you now have Thigh Boots of Wandering. If it is suppose to do this, it's not happening for me.

Rather after ID'ing NAME2 field is replaced by NAME1 field.

Thanks, i'll keep testing to see if I'm doing something wrong.

Good luck on midterms

/glad to be done with schooling...
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

I'll look into that.

You are exactly right....and I think Xuri picked up on it (since he's replied to my loremaster thread. :), I haven't read it yet.)

Before v3.3 of UOx, the name fields weren't working properly, i had to adjust the loremaster script to make it work. I had a nasty feeling it was going to bite me in the butt when they got the naming system fixed, and I guess it did.

Thanks for testing it out.
Lok1728
UOX3 Newbie
Posts: 14
Joined: Fri Feb 03, 2006 2:54 am
Has thanked: 0
Been thanked: 0

Post by Lok1728 »

Great - that bug Xuri found fixes the problem! It works great now!

http://uox3.org/forum/viewtopic.php?t=763
stranf
UOX3 Guru
Posts: 939
Joined: Wed Jan 04, 2006 3:59 pm
Has thanked: 0
Been thanked: 0

Post by stranf »

Fixed a bug that prevents a strength gain exploit while having the gloves worn while there is a server restart.
Post Reply