My ridiculous idea bag

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
Humility
UOX3 Neophyte
Posts: 28
Joined: Mon Nov 21, 2016 7:51 am
Has thanked: 4 times
Been thanked: 5 times

My ridiculous idea bag

Post by Humility »

I have an idea I think will help low population shards. If one is playing mainly by themselves
or with just a handful of friends, it may be tedious to maintain a player vendor "mall" given the dearth of
real customers.

My proposal is a wholly fascist one, lol. A small number of server controlled player vendors
occupying a small number of small houses that auto refill their own packs. They store a list of items placed in
their packs by the admin who owns them as well as the prices set and OnAiSliver() update a delay variable
after the variable counts reaches it's trigger value it iterates through the list and checks for the item
placed in the pack by the admin if it is missing it spawns a new one and sets the same price. I intend it to only replace 1 item per cycle
so it takes all day to refill it's pack fully. this is to give real vendors a chance to compete on growing shards while on solo shards it could be turned down to
an hour or so to make the vendor a bit more useful. I realize regular vendors would work just fine for this but the player vendor style interface is much faster and
less obvious that it is not owned by a real player.

any thoughts I can't seem to find any files for the player vendors but I'm still looking.

Code: Select all

//to be added
I posted the first idea and thought rather than make further posts without code I'd tuck a couple more ideas in this one for myself as a to do list I am less likely to lose. I'll share the scripts here when I get to them. if anyone has any thoughts or suggestions on any of these I'd love to hear them.

(Idea 2) dismounter floor tiles.

contact script that stores your mount as an appropriate figurine in your pack if you enter a no mounts permitted zone.
a thought for those that think mounted players in the library is somehow silly. <.<
Humility
UOX3 Neophyte
Posts: 28
Joined: Mon Nov 21, 2016 7:51 am
Has thanked: 4 times
Been thanked: 5 times

Post by Humility »

UOX3 take on the Spirit Shield scroll from Diablo 1.

The scroll does all the work, there are no scripts to apply to the character.

You assign this script to even a wheel of cheese and click it and it will convert it into the soul shield scroll.

When in scroll form it is just an inert scroll waiting to be clicked.

in flaming shield form it glides above your head with all the grace of an angry chicken.

When you take damage it trades 1|1 mana for health until you run out of mana.

If your mana hits 0 it drops back into your pack as an inert scroll.

Humility — Today at 5:39 AM
You can toggle out of it at any time and I put in there to shut it off if the player gets disconnected while their shield is out.
const fastFrame = 66;
const slowFrame = 333;

function onUseChecked(pUser, iUsed) {
    //Anti script crash - Please don't remove
    iUsed.SetTag("oldx", 0);
    iUsed.SetTag("oldy", 0);
    iUsed.SetTag("oldz", 0);
    if (iUsed.owner == null || iUsed.id == "0x227c") {
        //I enjoy exploiting the occasional unforseen weird thing that happens
        //others may not want that.
        //if you want errant shields that lost their owner to self destruct if clicked
        // uncomment the following
        // if (iUsed.id == "0x227c") {iUsed.Delete();} //somehow I am a formed shield and have tested to have no owner, screw this!
        // if (iUsed.id == "0x19ab") { iUsed.owner = pUser; }

        //If the owner is somehow lost to the void, ...
        //i.e an errant shield just floating there or a scroll previously owned laying about, reset the owner.
        iUsed.owner = null;
        iUsed.owner = pUser; //if you uncomment the self destruct code, comment this line out.

    }

    // non essential chicanery, feel free to delete this else block
    else if (!(iUsed.id == "0x19ab") && !(iUsed.id == "0x227c")) {
        //So it's a wheel of cheese, ...
        //* such magics, much sparkles *
        //you were saying ?
        iUsed.id = "0x227c";
        //This else condition is really just here so I can quickly
        //turn random junk into test items just by
        //assigning the script to any old thing.
        return false;
    }

    var objOwner = iUsed.owner;

    if (iUsed.id == "0x19ab" && iUsed.owner == pUser) {
        // fend off clicks in combat
        // I am the owner and my shield is up, let's take it down.
        iUsed.KillTimers(0);

        //if you want single use scrolls instead of a legendary reusable scroll
        //then comment this block out and uncomment the delete line after it.
        iUsed.id = "0x227c";
        iUsed.name = "a scroll of spirit shield";
        iUsed.dir = 0;
        //iUsed.Delete();

        iUsed.container = objOwner.pack;
        iUsed.KillTimers(0);


    } else if (iUsed.id == "0x19ab" && !(iUsed.owner == pUser)) { //I am NOT! the owner clicking the scroll
        return false;
    } else { //I am the owner clicking my scroll either in or out of my pack
        //BUT! is it locked down?
        if (iUsed.movable < 2) {
            objOwner.DoAction(17);
            pUser.TextMessage("Anál nathrach, ");
            pUser.TextMessage("orth’ bháis’s bethad,");
            pUser.TextMessage("do chél dénmha!");
            //convert scroll into shield

            iUsed.id = "0x19ab";
            iUsed.container = null;
            iUsed.name = "a spirit shield";
            iUsed.dir = 29;

            iUsed.SetTag("ShieldAge", 0);
        }
    }


    iUsed.StartTimer(fastFrame, 0, true);
    iUsed.worldnumber = objOwner.worldnumber;
    iUsed.x = objOwner.x - 1;
    iUsed.y = objOwner.y - 1;
    iUsed.z = objOwner.z + 16;
    //iUsed.Refresh();
    return false;
}

function onTimer(iUsed, timerID) {
    if (timerID == 0) {
        var objOwner = iUsed.owner;
        //var ShieldAge = iUsed.GetTag("ShieldAge", true)
        //ShieldAge++
        //if (ShieldAge > 60) {
        //    iUsed.KillTimers(0);
        //    iUsed.Delete()
        //} //Shield fails from age
        //first check if we have moved
        if ((iUsed.id == "0x19ab") && (!(iUsed.GetTag("oldx") == objOwner.x) || !(iUsed.GetTag("oldy") == objOwner.y) || !(iUsed.GetTag("oldz") == objOwner.z))) {
            //Yes! update and start timer
            iUsed.SetTag("oldx", objOwner.x);
            iUsed.SetTag("oldy", objOwner.y);
            iUsed.SetTag("oldz", objOwner.z);
            iUsed.StartTimer(fastFrame, 0, true);

            iUsed.worldnumber = objOwner.worldnumber;
            DoMovingEffect(iUsed.x, iUsed.y, iUsed.z, objOwner.x - 1, objOwner.y - 1, objOwner.z + 16, 0x19ab, 10, 1, false);
            iUsed.x = objOwner.x - 1;
            iUsed.y = objOwner.y - 1;
            iUsed.z = objOwner.z + 16;
        }
        else if (iUsed.id == "0x19ab")
        {
            //No! let it dally so the animation doesn't suffer
            iUsed.StartTimer(slowFrame, 0, true);

        }

        if (iUsed.id == "0x19ab") {
            if (objOwner.health < objOwner.maxhp && objOwner.mana > 0) {
                objOwner.mana -= 1;
                objOwner.health++;
            }
            //out of mana or logged out, turn it off.
            if (objOwner.mana == 0 || objOwner.online == false) {
                //    iUsed.KillTimers(0);
                //    iUsed.Delete()
                iUsed.KillTimers(0);
                onUseChecked(objOwner, iUsed);
            }
        }

        return true;
    }
}
Humility
UOX3 Neophyte
Posts: 28
Joined: Mon Nov 21, 2016 7:51 am
Has thanked: 4 times
Been thanked: 5 times

Post by Humility »

Here's another Diablo spell scroll. [Scroll of Town Portal]
This scroll has 1 destination per world number.
it also might be a little hinky to use if you're a criminal.
function onCollide(socket, pUser, iUsed) {
    doUse(socket.currentChar, iUsed);
    return true;
}

function onUseChecked(pUser, iUsed) {
    doUse(pUser, iUsed);
    return true;
}

function onTimer(iUsed, timerID) {
    if (timerID == 1) {
        let frameCount = iUsed.GetTag("frmCount");
        switch (frameCount) {
            case 0: iUsed.id = "0x1fde"; break;
            case 1: iUsed.id = "0x1fdf"; break;
            case 2: iUsed.id = "0x1fe0"; break;
            case 3: iUsed.id = "0x1fe1"; break;
            case 4:
                iUsed.id = "0x1fe2";
                iUsed.name = "a forming portal"
                break;
            case 5: iUsed.id = "0x1fe3"; break;
            case 6: iUsed.id = "0x1fe4"; break;
            case 7: iUsed.id = "0x1fe5"; break;
            case 8: iUsed.id = "0x1fe6"; break;
            case 9: iUsed.id = "0x1fe7"; break;
            case 10: iUsed.id = "0x1fe8"; break;
            case 11:
                iUsed.id = "0x1fe9";
                iUsed.name = "a town portal"
                break;
            case 12: iUsed.id = "0x1fea"; break;
            case 13:
                iUsed.KillTimers(1);
                iUsed.id = "0x0f6c";
                iUsed.movable = 2;
                break;
        }
        if (frameCount < 13) {
            frameCount++;
            iUsed.SetTag("frmCount", frameCount);
            iUsed.StartTimer(300, 1, true);
            return true;
        }
        iUsed.KillTimers(1);
        return true;
    } else
        if (timerID == 0) {
            iUsed.KillTimers(0);
            iUsed.Delete();
            return true;
        }
    return true;
}


function doUse(pUser, iUsed) {
    if (iUsed.id == "0x0f6c" && iUsed.InRange(pUser, 2)) //Is Gate
    {
        var objTraveller = pUser;
        var petList = objTraveller.GetPetList();
        var targX = 0; var targY = 0; var targZ = 0; var targM = 0;

        // teleport them
        if (objTraveller.worldnumber == 0) { targX = 1433; targY = 1704; targZ = 14; targM = 0; } //Brit - Fel
        if (objTraveller.worldnumber == 1) { targX = 1433; targY = 1704; targZ = 14; targM = 1; } //Brit Tram
        if (objTraveller.worldnumber == 2) { targX = 282; targY = 1016; targZ = 2; targM = 2; }   //Humility
        if (objTraveller.worldnumber == 3) { targX = 1015; targY = 527; targZ = -65; targM = 3; } //Luna
        if (objTraveller.worldnumber == 4) { targX = 801; targY = 1204; targZ = 25; targM = 4; } //Makoto Jima


        // Teleport player's pets - lifted from moongate.js
        for (var i = 0; i < petList.length; i++) {
            var tempPet = petList[i];
            if (ValidateObject(tempPet) && tempPet.InRange(objTraveller, 12) && tempPet.mounted == false) {
                tempPet.Teleport(targX, targY, targZ, targM, 0);
                tempPet.Follow(objTraveller);
            }
        }
        objTraveller.Teleport(targX, targY, targZ, targM, 0);

        // the BWA HAHAHAHAHAHHAHAHAHAHAHHAHAHAHAHAHAHHAHAHAHAHA block.
        if (objTraveller.criminal || objTraveller.murderer) {
            var packContents = new Array();
            // What have I done with my life? *empties pack on the ground and stares bleakly at the contents*

            objTraveller.frozen = true;
            objTraveller.textmessage("*empties pack on the ground and stares bleakly at the contents*")
            for (mItem = objTraveller.pack.FirstItem(); !objTraveller.pack.FinishedItems(); mItem = objTraveller.pack.NextItem()) {
                rndX = RandomNumber(-5, 5);
                rndY = RandomNumber(-5, 5);
                if (ValidateObject(mItem)) {
                    mItem.container = null;
                    mItem.Teleport(objTraveller.x + rndX, objTraveller.y + rndY, objTraveller.z, objTraveller.worldnumber);
                }
            }
            objTraveller.frozen = false;
            objTraveller.textmessage("Guards!!! I wish to turn myself in.")
        }
    }

    // admin convenience, turn a loaf of bread into a town portal scroll
    // just by assigning the script and clicking on it.
    else if (!(iUsed.id == "0x227b") && !(iUsed.id == "0x1fde") &&
        !(iUsed.id == "0x1fdf") && !(iUsed.id == "0x1fe0") &&
        !(iUsed.id == "0x1fe1") && !(iUsed.id == "0x1fe2") &&
        !(iUsed.id == "0x1fe3") && !(iUsed.id == "0x1fe4") &&
        !(iUsed.id == "0x1fe5") && !(iUsed.id == "0x1fe6") &&
        !(iUsed.id == "0x1fe7") && !(iUsed.id == "0x1fe8") &&
        !(iUsed.id == "0x1fe9") && !(iUsed.id == "0x1fea") &&
        !(iUsed.id == "0x0f6c")) {
        iUsed.KillTimers(0);
        iUsed.KillTimers(1);
        iUsed.id = "0x227b";
        iUsed.name = "a scroll of town portal";
        iUsed.movable = 1;
        iUsed.dir = 0;
        iUsed.container = pUser.pack;
        iUsed.moveable = 0;
        return false;

    } else if (iUsed.id == "0x227b")  {
        iUsed.container = null; //Drop it from pack
        iUsed.worldnumber = pUser.worldnumber;
        iUsed.x = pUser.x - 2;
        iUsed.y = pUser.y - 2;
        iUsed.z = pUser.z;
        iUsed.SetTag("frmCount", 0);

        //make portal spring up
        if (!pUser.isMounted) { pUser.DoAction(17); }
        pUser.SoundEffect(0x102, true);

        iUsed.StartTimer(30000, 0, true);
        iUsed.StartTimer(300, 1, true);
        iUsed.name = "a strange glow"
        iUsed.id = "0x1fde"; //turn the scroll into a gate
        iUsed.colour = "0x04AA"
        iUsed.dir = 29;      //make it glow
        iUsed.movable = 2;   //lock it down

    }
    return true;
}
Post Reply