Script of Blacksmith

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Script of Blacksmith

Post by Blue Dragon »

Xuri, below follows the script blacksmith if you want to analyze...

Note: I Only put these two ores in the moment, and the script is not totally complete / edited, but it works well.


Blacksmith Hammer
[marteloferreiroferro]
{
NAME=Martelo de Ferreiro    //Lingotes: 4
ID=0x0FB5           //ID=0x0FB4
COLOUR=0

HP=20

DAMAGE=2 8
SPEED=64

STRENGTH=0

LAYER=1

VALUE=200 100
WEIGHT=400
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0

SCRIPT=3704
}
Ingots of iron and mithril
[lingoteferro]
{
NAME=Lingote de Ferro
ID=0x1bf2           //ID=0x1bef
COLOR=0

VALUE=10 5
WEIGHT=10
RESTOCK=10

VISIBLE=0
MOVABLE=1
PILEABLE=1
DECAY=1
WIPE=0

AMOUNT=1
}

[lingotemithril]
{
NAME=Lingote de Mithril
ID=0x1bf2           //ID=0x1bef
COLOR=1151

VALUE=1000 500
WEIGHT=10
RESTOCK=10

VISIBLE=0
MOVABLE=1
PILEABLE=1
DECAY=1
WIPE=0

AMOUNT=1
}
Below is just the files of iron and mithril swords, so that someone can make an item (swords)...


Iron Swords
[punhalferro]
{
NAME=Punhal         //Lingotes: 4
ID=0x13F6           //ID=0x13F7
COLOUR=0

HP=20

DAMAGE=2 8
SPEED=64

STRENGTH=0

LAYER=1

VALUE=200 100
WEIGHT=400
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[katanaferro]
{
NAME=Katana         //Lingotes: 8
ID=0x13FF           //ID=0x13FE
COLOUR=0

HP=40

DAMAGE=8 28
SPEED=58

STRENGTH=20

LAYER=1

VALUE=400 200
WEIGHT=800
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[espadalargaferro]
{
NAME=Espada Larga       //Lingotes: 10
ID=0x0F5E           //ID=0x0F5F
COLOUR=0

HP=40

DAMAGE=14 26
SPEED=48

STRENGTH=20

LAYER=1

VALUE=500 250
WEIGHT=1000
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[espadalongaferro]
{
NAME=Espada Longa       //Lingotes: 12
ID=0x0F61           //ID=0x0F60
COLOUR=0

HP=40


DAMAGE=6 32
SPEED=40

STRENGTH=20

LAYER=1

VALUE=600 300
WEIGHT=1200
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[cuteloferro]
{
NAME=Cutelo         //Lingotes: 8
ID=0x1441           //ID=0x1440
COLOUR=0

HP=40

DAMAGE=8 22
SPEED=60

STRENGTH=20

LAYER=1

VALUE=400 200
WEIGHT=800
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[cimitarraferro]
{
NAME=Cimitarra          //Lingotes: 12
ID=0x13B6           //ID=0x13B5
COLOUR=0

HP=40

DAMAGE=12 24
SPEED=50

STRENGTH=20

LAYER=1

VALUE=600 300
WEIGHT=1200
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[espadabastardaferro]
{
NAME=Espada Bastarda        //Lingotes: 16
ID=0x13B9           //ID=0x13BA
COLOUR=0

HP=50

DAMAGE=16 34
SPEED=38

STRENGTH=40

LAYER=1

VALUE=800 400
WEIGHT=1600
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[claymoreferro]
{
NAME=Claymore           //Lingotes: 20
ID=0x26CF           //ID=0x26CE
COLOUR=0

HP=60

DAMAGE=20 40
SPEED=30

STRENGTH=60

LAYER=2

VALUE=1000 500
WEIGHT=2000
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}
Mithril Swords
[punhalmithril]
{
NAME=Punhal         //Lingotes: 4
ID=0x13f6           //ID=0x13F7
COLOUR=1151

HP=70

DAMAGE=22 28
SPEED=64

STRENGTH=0

LAYER=1

VALUE=200 100
WEIGHT=400
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[katanamithril]
{
NAME=Katana         //Lingotes: 8
ID=0x13FF           //ID=0x13FE
COLOUR=1151

HP=90

DAMAGE=28 48
SPEED=58

STRENGTH=20

LAYER=1

VALUE=400 200
WEIGHT=800
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[espadalargamithril]
{
NAME=Espada Larga       //Lingotes: 10
ID=0x0F5E           //ID=0x0F5F
COLOUR=1151

HP=90

DAMAGE=34 46
SPEED=48

STRENGTH=20

LAYER=1

VALUE=500 250
WEIGHT=1000
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[espadalongamithril]
{
NAME=Espada Longa       //Lingotes: 12
ID=0x0F61           //ID=0x0F60
COLOUR=1151

HP=90


DAMAGE=26 52
SPEED=40

STRENGTH=20

LAYER=1

VALUE=600 300
WEIGHT=1200
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[cutelomithril]
{
NAME=Cutelo         //Lingotes: 8
ID=0x1441           //ID=0x1440
COLOUR=1151

HP=90

DAMAGE=28 42
SPEED=60

STRENGTH=20

LAYER=1

VALUE=400 200
WEIGHT=800
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[cimitarramithril]
{
NAME=Cimitarra          //Lingotes: 12
ID=0x13B6           //ID=0x13B5
COLOUR=1151

HP=90

DAMAGE=32 44
SPEED=50

STRENGTH=20

LAYER=1

VALUE=600 300
WEIGHT=1200
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[espadabastardamithril]
{
NAME=Espada Bastarda        //Lingotes: 16
ID=0x13B9           //ID=0x13BA
COLOUR=1151

HP=100

DAMAGE=36 54
SPEED=38

STRENGTH=40

LAYER=1

VALUE=800 400
WEIGHT=1600
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}


[claymoremithril]
{
NAME=Claymore           //Lingotes: 20
ID=0x26CF           //ID=0x26CE
COLOUR=1151

HP=110

DAMAGE=40 60
SPEED=30

STRENGTH=60

LAYER=2

VALUE=1000 500
WEIGHT=2000
RESTOCK=5

VISIBLE=0
MOVABLE=1
DECAY=1
WIPE=0
}
Last edited by Blue Dragon on Tue Oct 23, 2012 4:31 pm, edited 2 times in total.
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

Blacksmithing - Version 2
Attachments
blacksmith in English.rar
(5.59 KiB) Downloaded 148 times
Last edited by Blue Dragon on Mon Oct 29, 2012 10:43 pm, edited 3 times in total.
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

Xuri, if not uncomfortable and you know the answer, I would take some doubts about my script.

1 - In the stretch below, the player to click twice on the hammer, if his hands are empty, he equips the hammer and the target appears. If he is busy with his hand, appears the phrase that their hands are busy at the moment. Everything works fine, until you are with a two-handed weapon equipped, he equips the hammer with weapon. How to fix it?
if (LeftHand pUser.FindItemLayer = (0x01))
{
if (LeftHand pUser.FindItemLayer = (0x01) && iUsed.container == pUser.pack)
{
pUser.SysMessage ("Your hands are busy at the moment.");
}
}
else
{
iUsed.container = put;
iUsed.layer = 0x01;
}
2 - In the OnTimer function in timerId == 1 we have the stretch below. Would cause the UseResource is the MyTarget of the function onCallback0?
pUser.UseResource (4, 0x1bf2, 0);
3 - In gumps of "OtherButton == 0, == 1, == 2 ..." have the stretch below. It would be possible to limit this space fill to not accept more than 3 digits (numbers) and not letters? This space would be to put the amount of items that the player would do. The maximum number would be 50.

4- From Item 3, as is done for the script to repeat the action in accordance with the amount placed? For example, you click longsword and put quantity 50, if the character has enough material in his backpack, he would do 50 longswords without the player having to repeat this action 50 times.

If have there something that is very complicated and complex, you can leave...
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 »

1) This bit will give the player the systemmessage if either his left or his right hand is occupied:
var LeftHand = pUser.FindItemLayer( 0x01 );
var RightHand = pUser.FindItemLayer( 0x02 );
if( LeftHand || RightHand )
{
    pUser.SysMessage( "Suas maos estao ocupadas no momento." );
}
else
{
    iUsed.container = pUser;
    iUsed.layer = 0x01;
}
2) Could you rephrase the question, please?

3) Using AddTextEntry I don't think you can limit the amount of text a user can enter (hmm unless you can do that through parameter 6 in the function? not sure). You can, however, check what the user entered in the onGumpPress function and slap him on the wrist and say "No! Try again. Max 50" and re-open the gump :) Also, the following gump-method is up on the CVS (will be available in next UOX3 release):

Code: Select all

AddTextEntryLimited( left, top, width, height, hue, relay, initialTextIndex, actualText, size ) // Add a text-entry gump with restriction on entry-length
...but you would still have to double-check the result to make sure it is numbers and not letters (or the other way around).

4) Not sure what a good way of achieving this would be.
-= Ho Eyo He Hum =-
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

1- Ok! Thanks.

2 - Xuri, for example, when the character will use the resource (material), you use "pUser.UseResource (4, 0x1bf2, 0);". Where would decrease 4 ingots of original color (0) from the character's backpack. I would like to know if do something like "pUser.UseResource (4, myTarget);" or something like that, where instead of putting an ID, put a reference, in the case the reference would be myTarget of the function onCallBack0? Soon he would decrease 4 ingots of selected target.

One reason for this, if possible, that is, assuming the character has two stacks of ingots the same color in your bag . Sometimes it decreases the amount of another pile of ingots you did not clicked (selected). There is nothing very important, but it's weird, because you selected a pile and the material is consumed from another pile? It also has other reasons, but they are not very relevant.

3- Great! Thanks.

4- I think it would be kind of a loop. I think that part would enter those functions i + + or + + i definitely do not understand it xD. But that's okay.
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 »

For 2), you might be able to do that by first setting, in onCallback:
socket.tempObj = myTarget;
...and then in onTimer you use something like this:
var myTarget = pUser.socket.tempObj;
if( myTarget && myTarget.id == 0x1bf2 && myTarget.amount >= 4 )
{
    // If the targeted resource-pile is big enough, reduce it by the amount of resources used to create the item
    myTarget.amount -= 4;
}
else
{
    // The targeted resource-pile was not big enough, so instead just reduce it by doing a generic search for the ID
    if( pUser.ResourceCount( 0x1bf2 ) >= 4 )
        pUser.UseResource (4, 0x1bf2, 0)
    else
        pUser.SysMessage( "W0ot! You don't have enough resources on hand. Nice try, buddy!" );
}
-= Ho Eyo He Hum =-
Blue Dragon
UOX3 Apprentice
Posts: 159
Joined: Mon Jan 09, 2012 1:43 am
Has thanked: 0
Been thanked: 0

Post by Blue Dragon »

Thanks for the replies Xuri.

Updated the script to a version 2.

- Added the ID's of all weapons, armors and shields (which can be created in the script) to be repaired;

- Improved some things, especially in system of repairs;

- The repair of weapons/armors is now fully functioning;

- Figures of the gump adjusted a little better;

- Translated phrases of the gump and actions of this script for English (not sure if the translation was good, but it helps for those who want to test);

- Fixed some bug's;

- Added a limit on the amount of fill-in field for just 50. Above that value, is invalid!
Post Reply