AOS Fletching Gump v1.0

Got any custom JavaScript additions/tweaks you think other people would like to see? Post 'em here!
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

AOS Fletching Gump v1.0

Post by dragon slayer »

Here i created a AOS fletching version 1.0
Missing features
resmelt
make last
make last 10
make all boards or logs into shafts or arrows
Display the error msgs in the gump no idea how yet
Item details buttons when clicked will tell you how much logs or boards you need, skill needed chance and success of making item.

Got it to redisplay gump with a cheap trick but needs to be done right so goes straight back to the page open.

I could use some help on this one guys just a start :)
function onUseChecked( pUser, iUsed )
{
    var socket = pUser.socket;
    if( socket && iUsed && iUsed.isItem )
    {
                iUsed.health -= 1;
                if(iUsed.health == 0)
                {
                  iUsed.Delete();
                  pUser.SysMessage( "You have worn out your tool!" );
              return false;
                }
                else
                     socket.tempObj = iUsed;
                     var ret=displaygump(socket, pUser);
    }
    return false;
}

function displaygump(socket, pUser)
{
              var myGump = new Gump; // create a new gump
              myGump.AddPage(0);
              myGump.AddBackground( 0, 0, 530, 437, 5054 );
              myGump.AddTiledGump( 10, 10, 510, 22, 2624 );
              myGump.AddTiledGump( 10, 292, 150, 45, 2624 );
              myGump.AddTiledGump( 165, 292, 355, 45, 2624 );
              myGump.AddTiledGump( 10, 342, 510, 85, 2624 );
              myGump.AddTiledGump( 10, 37, 200, 250, 2624 );
              myGump.AddTiledGump( 215, 37, 305, 250, 2624 );
              myGump.AddCheckerTrans( 10, 10, 510, 417 );
              myGump.AddXMFHTMLGumpColor( 10, 12, 510, 20, 1044006, false, false, 0x7FFF );//name of craft
              myGump.AddXMFHTMLGumpColor( 10, 37, 200, 22, 1044010, false, false, 0x7FFF ); // <CENTER>CATEGORIES</CENTER>
              myGump.AddXMFHTMLGumpColor( 215, 37, 305, 22, 1044011, false, false, 0x7FFF ); // <CENTER>SELECTIONS</CENTER>
              myGump.AddXMFHTMLGumpColor( 10, 302, 150, 25, 1044012, false, false, 0x7FFF ); // <CENTER>NOTICES</CENTER>
              myGump.AddButton( 15, 402, 0x0fb1, 1, 0, 0 );
              myGump.AddXMFHTMLGumpColor( 50, 405, 150, 18, 1011441, false, false, 0x7FFF ); // EXIT
              myGump.AddButton( 270, 402, 0xfa5, 0, 0, 0 );
              myGump.AddXMFHTMLGumpColor( 305, 405, 150, 18, 1044013, false, false, 0x7FFF ); // MAKE LAST
              myGump.AddButton( 270, 362, 0xfa5, 0, 0, 0 );
              myGump.AddXMFHTMLGumpColor( 305, 365, 150, 18, 1044017, false, false, 0x7FFF ); // MARK ITEM
              myGump.AddButton( 15, 342, 0xfa5, 0, 0, 0 );
              myGump.AddXMFHTMLGumpColor( 50, 345, 150, 18, 1044259, false, false, 0x7FFF ); // SMELT ITEM
              myGump.AddButton( 270, 342, 0xfa5, 1, 0, 20 );
              myGump.AddXMFHTMLGumpColor( 305, 345, 150, 18, 1044260, false, false, 0x7FFF ); // REPAIR ITEM
              myGump.AddButton( 270, 382, 0xfa5, 0, 0, 0 );
              myGump.AddXMFHTMLGumpColor( 305, 385, 150, 18, 1061001, false, false, 0x7FFF ); // ENHANCE ITEM

              myGump.AddButton( 15, 60, 0xfa5, 0, 0, 0 );
              myGump.AddXMFHTMLGumpColor( 50, 63, 150, 18, 1044014, false, false, 0x7FFF ); // LAST TEN
              myGump.AddXMFHTMLGumpColor( 50, 83, 150, 18, 1044457, false, false, 0x7FFF );//Materials
              myGump.AddButton( 15, 80, 0xfa5, 0, 1, 0 );
              myGump.AddXMFHTMLGumpColor( 50, 103, 150, 18, 1044565, false, false, 0x7FFF );//Ammunition
              myGump.AddButton( 15, 100, 0xfa5, 0, 2, 0 );
              myGump.AddXMFHTMLGumpColor( 50, 123, 150, 18, 1044566, false, false, 0x7FFF );//Weapons
              myGump.AddButton( 15, 120, 0xfa5, 0, 3, 0 );

              myGump.AddPage(1);
              myGump.AddXMFHTMLGumpColor( 255, 63, 220, 18, 1023553, false, false, 0x7FFF );//Kindling
              myGump.AddButton( 220, 60, 0xfa5, 1, 0, 1 );
              myGump.AddXMFHTMLGumpColor( 255, 83, 220, 18, 1027124, false, false, 0x7FFF );//Shaft
              myGump.AddButton( 220, 80, 0xfa5, 1, 0, 2 );

              myGump.AddPage(2);
              myGump.AddXMFHTMLGumpColor( 255, 63, 220, 18, 1023903, false, false, 0x7FFF );//Arrow
              myGump.AddButton( 220, 60, 0xfa5, 1, 0, 12 );
              myGump.AddXMFHTMLGumpColor( 255, 83, 220, 18, 1027163, false, false, 0x7FFF );//Bolt
              myGump.AddButton( 220, 80, 0xfa5, 1, 0, 16 );
              myGump.AddXMFHTMLGumpColor( 255, 103, 220, 18, 1030246, false, false, 0x7FFF );//FukiyaDarts
              myGump.AddButton( 220, 100, 0xfa5, 1, 0, 0 );

              myGump.AddPage(3);
              myGump.AddXMFHTMLGumpColor( 255, 63, 220, 18, 1025042, false, false, 0x7FFF );//Bow
              myGump.AddButton( 220, 60, 0xfa5, 1, 0, 6 );
              myGump.AddXMFHTMLGumpColor( 255, 83, 220, 18, 1023919, false, false, 0x7FFF );//CrossBow
              myGump.AddButton( 220, 80, 0xfa5, 1, 0, 7 );
              myGump.AddXMFHTMLGumpColor( 255, 103, 220, 18, 1025117, false, false, 0x7FFF );//heavy CrossBow
              myGump.AddButton( 220, 100, 0xfa5, 1, 0, 8 );
              myGump.AddXMFHTMLGumpColor( 255, 123, 220, 18, 1029922, false, false, 0x7FFF );//CompositeBow
              myGump.AddButton( 220, 120, 0xfa5, 1, 0, 9 );
              myGump.AddXMFHTMLGumpColor( 255, 143, 220, 18, 1029923, false, false, 0x7FFF );//RepeatingCrossbow
              myGump.AddButton( 220, 140, 0xfa5, 1, 0, 10 );
              myGump.AddXMFHTMLGumpColor( 255, 163, 220, 18, 1030224, false, false, 0x7FFF );//Yumi
              myGump.AddButton( 220, 160, 0xfa5, 1, 0, 11 );

                  myGump.Send( socket ); // send this gump to client now
                  myGump.Free(); // clear this gump from uox-memory
                  return false;
}

function onGumpPress( pSock, pButton, gumpData )
{
    var pUser = pSock.currentChar;
    var bItem = pSock.tempObj;
    switch(pButton)
    {
        case 0:
                       pSock.tempObj = null;
               break;// abort and do nothing
        case 1:
               MakeItem( pSock, pUser, 190 );
                       var ret=displaygump(pSock, pUser);
               break;//Kindling
        case 2:
               MakeItem( pSock, pUser, 194 );
                       var ret=displaygump(pSock, pUser);
               break;//One Shaft
        case 3:
               MakeItem( pSock, pUser, 195 );
                       var ret=displaygump(pSock, pUser);
               break;//Five Shafts
        case 4:
               MakeItem( pSock, pUser, 196 );
                       var ret=displaygump(pSock, pUser);
               break;//twenty shafts
        case 5:
               MakeItem( pSock, pUser, 197 );
                       var ret=displaygump(pSock, pUser);
               break;//fifty shafts
        case 6:
               MakeItem( pSock, pUser, 191 );
                       var ret=displaygump(pSock, pUser);
               break;//Bow
        case 7:
               MakeItem( pSock, pUser, 192 );
                       var ret=displaygump(pSock, pUser);
               break;//Crossbow
        case 8:
               MakeItem( pSock, pUser, 193 );
                       var ret=displaygump(pSock, pUser);
               break;//Heavy Crossbow
        case 9:
               MakeItem( pSock, pUser, 206 );
                       var ret=displaygump(pSock, pUser);
               break;//Composite Bow
        case 10:
               MakeItem( pSock, pUser, 207 );
                       var ret=displaygump(pSock, pUser);
               break;//repeating crossbow
        case 11:
               MakeItem( pSock, pUser, 208 );
                       var ret=displaygump(pSock, pUser);
               break;//yumi
        case 12:
               MakeItem( pSock, pUser, 198 );
                       var ret=displaygump(pSock, pUser);
               break;//One Arrow
        case 13:
               MakeItem( pSock, pUser, 199 );
                       var ret=displaygump(pSock, pUser);
               break;//Five Arrows
        case 14:
               MakeItem( pSock, pUser, 200 );
                       var ret=displaygump(pSock, pUser);
               break;//Twenty Arrows
        case 15:
               MakeItem( pSock, pUser, 201 );
                       var ret=displaygump(pSock, pUser);
               break;//Fifty Arrows
        case 16:
               MakeItem( pSock, pUser, 202 );
                       var ret=displaygump(pSock, pUser);
               break;//One Bolt
        case 17:
               MakeItem( pSock, pUser, 203 );
                       var ret=displaygump(pSock, pUser);
               break;//Five Bolts
        case 18:
               MakeItem( pSock, pUser, 204 );
                       var ret=displaygump(pSock, pUser);
               break;//twenty Bolts
        case 19:
               MakeItem( pSock, pUser, 205 );
                       var ret=displaygump(pSock, pUser);
               break;//Fifty Bolts
        case 20:
               var targMsg = GetDictionaryEntry( 485, pSock.Language );
               pSock.CustomTarget(1, targMsg );break;
    }
}

function onCallback1( socket, ourObj )
{
    var mChar = socket.currentChar;
    var bItem = socket.tempObj;
    socket.tempObj = null;

    if( mChar && mChar.isChar && bItem && bItem.isItem )
    {
        if( !ourObj || !ourObj.isItem )
        {
            socket.SysMessage( GetDictionaryEntry( 986, socket.Language ) );
            return;
        }

        var minSkill = 999;
        var maxSkill = 1000;
        // This needs to use getWeaponType eventually
        var weaponID = ourObj.id;
        if( weaponID == 0x13B1 || weaponID == 0x13B2 || weaponID == 0x26C2 || weaponID == 0x26CC ||
            weaponID == 0x2571 || weaponID == 0x0F4F || weaponID == 0x0F50 || weaponID == 0x13FC ||
            weaponID == 0x13FD || weaponID == 0x26C3 || weaponID == 0x26CD || weaponID == 0x27A5 ||
            weaponID == 0x27F0 )    // Is it a bow?
        {
            var ownerObj = GetPackOwner( ourObj, 0 );
            if( ownerObj && mChar.serial == ownerObj.serial )
            {
                if( ourObj.health < ourObj.maxhp )
                {
                    if( ourObj.hidamage > 0 )
                    {
                        var offset = ((ourObj.lodamage + ourObj.hidamage) / 2);
                        if( offset <= 25 )
                        {
                            minSkill = (510 + ((offset - 1) / 5) * 100);
                            maxSkill = (799 + ((offset - 1) / 5) *50);
                        }
                    }
                    else
                    {
                        socket.SysMessage( GetDictionaryEntry( 987, socket.Language ) );
                        return;
                    }

                    if( mChar.CheckSkill( 8, minSkill, maxSkill ) )
                    {
                        ourObj.health = ourObj.maxhp;
                        socket.SysMessage( GetDictionaryEntry( 989, socket.Language ) );
                        socket.SoundEffect( 0x002A, true );
                                                var ret=displaygump(socket, pUser);
                    }
                    else
                        socket.SysMessage( GetDictionaryEntry( 990, socket.Language ) );
                                                var ret=displaygump(socket, pUser);
                }
                else
                    socket.SysMessage( GetDictionaryEntry( 988, socket.Language ) );
                                        var ret=displaygump(socket, pUser);
            }
            else
                socket.SysMessage( "You must have that item in your pack to repair it!" );
                                var ret=displaygump(socket, pUser);
        }
        else
            socket.SysMessage( GetDictionaryEntry( 986, socket.Language ) );
                        var ret=displaygump(socket, pUser);
    }
}
Post Reply