Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Pokemon Attacker(uses PKMN references) and Urbandictionary Definer (uses chat ref)

Code
// VARIABLE
    // ******** ******** ********
    var vMessage = message;
    var vOtherDefine = true;
    var UNK = ""
    var vChannel = client.channelName(channel);
    var vMyName = client.ownName();
    var vUserSent = vMessage.substring(0, vMessage.indexOf(':'));
    var min = 1;
    var max = 2000;
    var dmg = Math.floor(Math.random() * (max - min + 1)) + min;
    var minZ = 1;
    var maxZ = 616;
    var dmgZ = Math.floor(Math.random() * (maxZ - minZ + 1)) + minZ;
    var vChannelPlayerID = client.channel(channel).players();
    var vChannelPlayerName = [];
    for (var x = 0; x < vChannelPlayerID.length; x++){
    vChannelPlayerName[x] = client.name(vChannelPlayerID[x]);
    }
    var vRndm = vChannelPlayerName[Math.floor((Math.random()*vChannelPlayerName.length)+0)];
    var vMoveName = [];
    var vMoveNameDone = false;
    for (x=0; vMoveNameDone == false; x++){
    vMoveName[x] = sys.move(x);
    if (vMoveName[x] == undefined){
    vMoveNameDone = true;
   // REMOVE (No Move)
   vMoveName.shift();
   // REMOVE LAST ENTRY undefined
   vMoveName.pop()
   vMove = vMoveName[dmgZ]
   }
   }


    // EXTRACT MESSAGE BY TAKING OUT THE NAME
    if (vMessage.indexOf(':') >= 0) {vMessage = vMessage.substr(vMessage.indexOf(':') + 2);}
    // SET THE MESSAGE MESSAGE TEXT TO LOWERCASE
    vMessage = vMessage.toLowerCase();


   //Pokemon Attack        
           if (["-move"].indexOf(vMessage) !== -1){
        if (dmg > 1500)        
        UNK = " Critical";
        else
        UNK = " Regular";
            var vName = "/me ±Ditto: ";
            var vMsg = [];
            vMsg[0] = vUserSent + " used " + vMove + ", it dealt " + dmg + UNK + " Damage to " + vRndm;
            vMsg[1] = vUserSent + " used " + vMove + ", it missed!... " + vRndm + " was unharmed!";
            var vRNG = Math.floor((Math.random()*vMsg.length)+0);
            if (vUserSent == vMyName) {vRndm = "their self!?!"}
            client.network().sendChanMessage(channel, vName + vMsg[vRNG]);
            }
          
// DEFINE
                    // ******** ******** ********
                    var vCommand = "-def";
                    if (((vCommand == vMessage.substring(0, vCommand.length)) && (vMyName == vUserSent)) || ((vCommand == vMessage.substring(0, vCommand.length)) && (vOtherDefine == true))) {
                        var vCommand = vMessage.substring(vCommand.length + 1).toUpperCase();
                        // WHO REQUESTED AND WHERE CHECK
                        if (vMyName == vUserSent){
                            print(vName + "Obtaining definition from Urban Dictionary…");
                            }
                        var vResponse = sys.synchronousWebCall("http://api.urbandictionary.com/v0/define?term=" + (encodeURIComponent(vCommand)));
                        var vDef = JSON.parse(vResponse);
                        if (vMyName == vUserSent){
                            print(vName + "Done.");
                            }
                        if (vDef.result_type != "exact") {
                            client.network().sendChanMessage(channel, vCommand + " is fake, gay and not defined!")
                            }
                        else {
                            // OBTAIN STRING TO ALLOW LENGTH CHECK
                            var vDefString = vDef.list[0].definition;
                            var vStringLimit = 300;
                            if (vDefString.length <= vStringLimit){
                                client.network().sendChanMessage(channel, vCommand + ": " + vDefString);
                                }
                            if (vDefString.length > vStringLimit){
                                client.network().sendChanMessage(channel, vCommand + ": " + vDefString.substring(0, vStringLimit) + " [String Limit of "+ vStringLimit + " Reached]");
                                }
                            }
                        }


These codes a for an auto response bot for a Netplay client. I programmed it my self, the first one "Pokemon attack" is just a 'randomized' auto response to Get a Random User From the Channel list and then "attack" them with a random "Move" (actual move references) and an randomized damage / critical.

As for the Urbandictionary reference im sure someone has made it before, but probably not the way I did it. Either way I just felt like posting this somewhere.
This is Java Script not Java, please post this thread in the web development section.
(Mar 9, 2014 12:15 PM)matt Wrote:  This is Java Script not Java, please post this thread in the web development section.

Javascript is java? Sorry I learned javascript just to make this, but later got banned.
(Mar 9, 2014 01:25 PM)Utilisupport Wrote:  Javascript is java? Sorry I learned javascript just to make this, but later got banned.

No javascript isnt java. the names are very misleading, there is actually no relation between java and javascript. here is an amusing description of javascript:

"1995 - Brendan Eich reads up on every mistake ever made in designing a programming language, invents a few more, and creates LiveScript. Later, in an effort to cash in on the popularity of Java the language is renamed JavaScript. Later still, in an effort to cash in on the popularity of skin diseases the language is renamed ECMAScrip."

Source, the best history of programming languages i have ever read: http://james-iry.blogspot.co.nz/2009/05/...wrong.html


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by LuunaJan 21, 2022 10:13 AM 0 112 Jan 21, 2022 10:13 AM
Last Post: Luuna
[Python] by CryptJan 19, 2021 10:40 AM 11 378 Jan 19, 2021 10:40 AM
Last Post: ThinWhiteDuke
[Python] by 0NUR0UXJan 16, 2017 07:35 PM 7 192 Jan 16, 2017 07:35 PM
Last Post: 0NUR0UX