GM: Looking for help with a script please :)

Discussion in 'Code Snippets and Tutorials' started by CoS, Apr 11, 2009.

  1. CoS

    CoS Level IV

    Joined:
    Jun 16, 2008
    Messages:
    1,090
    Likes Received:
    35
    I am using the NQ2 trainer and i recently added Mipsy to my party. My skills are different for her than what are stated in the script.
    script (Casts group haste, then does direct damage)
    mine is just (just Group Direct Damage)

    I was wondering if anybody could edit the script so that Mipsy casts Group Direct Damage and then does direct damage.
    I dont even know where to start
    This is the script:

    Code (Text):
    1. // ==UserScript==
    2. // @name           NeoQuest II Trainer
    3. // @namespace      http://nq2guy.tz/
    4. // @description    Automatically battles and moves left and right for you.
    5. // @include        http://www.neopets.com/games/nq2/nq2.phtml*
    6. // ==/UserScript==
    7.  
    8. //script licensed under, GNU GPL V3 , see http://www.gnu.org/licenses/gpl.txt for details
    9. //uncomment these lines to initialize variables
    10.  
    11. //Check for annoying server hiccup before bothering to make any more variables
    12. var i = 0;
    13. var hiccup=1;
    14. var divs = document.getElementsByTagName('div');
    15. for(i=0;i<divs.length;i++)
    16. {
    17.     if(divs[i].className=="contentModuleHeader")
    18.     {
    19.         hiccup=0;
    20.     }
    21. }
    22.  
    23. if(hiccup)
    24. {
    25.     document.location.href="http://www.neopets.com/games/nq2/nq2.phtml";
    26. }
    27. else
    28. {
    29. //begin real battling!!
    30. var useid=-1; // use special item??
    31. var nxactor=1; // who fightsS??' default =1: rohane
    32. var fact=3; // default is attack , will override for low health
    33. var hitTarget = GM_getValue("hitTarget",5); //hittargets 1-4 are reserved for allies
    34. var healingItem = GM_getValue("healingItem",30033); // get the healing item in case HP turns red or yellow
    35. var isHasted = GM_getValue("isHasted",false);
    36. var j=0; // used for looping to find out whose turn is it
    37. var elements = document.getElementsByTagName('img');
    38. for(i=0;i<elements.length;i++)
    39. {
    40.     switch(elements[i].src)
    41.     {
    42.     case "http://images.neopets.com/nq2/x/com_begin.gif":
    43.         GM_setValue("hitTarget",5);
    44.         GM_setValue("isHasted",false);
    45.         document.location.href="http://www.neopets.com/games/nq2/nq2.phtml?start=1";
    46.         break;
    47.     case "http://images.neopets.com/nq2/x/com_atk.gif":
    48.         var texts = document.getElementsByTagName("font");
    49.         var doMultipleTargets = 0;
    50.         for(j=0;j<texts.length;j++)
    51.         {
    52.             //check to increment target
    53.             if(((texts[j].innerHTML.search(/for it has already been defeated!/)) != -1) || (texts[j].innerHTML=="You must select a valid target to cast on!<BR>"))
    54.             {
    55.                 hitTarget++;
    56.                 if(hitTarget>=9)
    57.                 {
    58.                 GM_setValue("hitTarget",5);
    59.                 }
    60.                 else
    61.                 {
    62.                 GM_setValue("hitTarget",hitTarget);
    63.                 }
    64.             }
    65.             //check character's status
    66.             switch(texts[j].innerHTML)
    67.             {
    68.             case "<b>Rohane</b>":
    69.                 if((texts[j+1].color=="#d0d000") || (texts[j+1].color=="red"))
    70.                 {
    71.                     fact=5;
    72.                     useid = healingItem;
    73.                 }
    74.                 break;
    75.             case "<b>Mipsy</b>":
    76.                 nxactor=2;
    77.                 fact=9201; //use direct damage
    78.                 if(!isHasted)
    79.                 {
    80.                     fact=9203;
    81.                     GM_setValue("isHasted",true);
    82.                 }
    83.                 if((texts[j+1].color=="#d0d000") || (texts[j+1].color=="red"))
    84.                 {
    85.                     fact=5;
    86.                     useid = healingItem;
    87.                 }
    88.                 break;
    89.             case "<b>Talinia</b>":
    90.                 var multipleTargets = /Multiple Targets/;
    91.                 var k=0;
    92.                 var links = document.getElementsByTagName('a');
    93.                 for(k=0;k<links.length;k++)
    94.                 {
    95.                     if((links[k].innerHTML.search(multipleTargets)) != -1)
    96.                     {  
    97.                         fact = 9302;
    98.                     }
    99.                 }
    100.                 nxactor=3;
    101.                 if((texts[j+1].color=="#d0d000") || (texts[j+1].color=="red"))
    102.                 {
    103.                     fact=5;
    104.                     useid = healingItem;
    105.                 }
    106.                 break;
    107.             case "<b>Velm</b>":
    108.                 var l=0; // loops to see if velm is wasting his time healing
    109.                 var fullhp = 0; //if its 4 then all 4 people are fully healed
    110.                 var allies = false;
    111.                 //loop through all pictures if it's velm's turn
    112.                 for(l=0;l<elements.length;l++)
    113.                 {
    114.                     //makes sure the script isn't checking enemies hp
    115.                     if(elements[l].src=="http://images.neopets.com/nq2/x/donothing.gif")
    116.                     {
    117.                         allies = true;
    118.                     }
    119.                     //if checking allies HP
    120.                     if(allies)
    121.                     {
    122.                         //is the picture a health bar?
    123.                         if(elements[l].src=="http://images.neopets.com/nq2/x/exp_green.gif")
    124.                         {
    125.                             if(elements[l].width == 45) //45 is full health
    126.                             {
    127.                                 fullhp++;
    128.                             }
    129.                         }
    130.                     }
    131.                 }
    132.                 nxactor=4;
    133.                 fact=9402; // velm heals, trust me you will need this
    134.                 if(fullhp == 4)
    135.                 {
    136.                     fact = GM_getValue("VelmAction",9403);
    137.                 }
    138.                 if((texts[j+1].color=="#d0d000") || (texts[j+1].color=="red"))
    139.                 {
    140.                     fact=5;
    141.                     useid = healingItem;
    142.                 }
    143.  
    144.                 break;
    145.                
    146.             }
    147.         }
    148.         document.location.href="http://www.neopets.com/games/nq2/nq2.phtml?&fact=" + fact + "&target=" + hitTarget + "&use_id=" + useid + "&nxactor=" + nxactor;
    149.         break;
    150.     case "http://images.neopets.com/nq2/x/com_next.gif":
    151.         document.location.href="javascript:setaction(1); document.ff.submit();";
    152.         break;
    153.     case "http://images.neopets.com/nq2/x/com_end.gif":
    154.         document.location.href="javascript:setaction(2); document.ff.submit();";
    155.         break;
    156.     case "http://images.neopets.com/nq2/x/tomap.gif":
    157.         GM_setValue("hitTarget",5);
    158.         GM_setValue("isHasted",false);
    159.         document.location.href="http://www.neopets.com/games/nq2/nq2.phtml?finish=1";
    160.         break;
    161.     case "http://images.neopets.com/nq2/x/nav.gif":
    162.         if(GM_getValue("goLeft"))
    163.         {
    164.             document.location.href="javascript:dosub(3)";
    165.             GM_setValue("goLeft",false);
    166.         }
    167.         else   
    168.         {
    169.             document.location.href="javascript:dosub(4)";
    170.             GM_setValue("goLeft",true);
    171.         }
    172.         break;
    173.     }
    174.  
    175. }
    176. }
    177. window.setTimeout(function() { document.location.href="http://www.neopets.com/games/nq2/nq2.phtml" }, 10000);
     
  2. Zer0

    Zer0 Level IV

    Joined:
    Mar 2, 2008
    Messages:
    3,037
    Likes Received:
    180
    Location:
    Home sweet home
    Here is my modified script:
    Code (Text):
    1. // ==UserScript==
    2. // @name           NeoQuest II Trainer
    3. // @namespace      http://nq2guy.tz/
    4. // @description    Automatically battles and moves left and right for you.
    5. // @include        http://www.neopets.com/games/nq2/nq2.phtml*
    6. // ==/UserScript==
    7.  
    8. //script licensed under, GNU GPL V3 , see http://www.gnu.org/licenses/gpl.txt for details
    9. //uncomment these lines to initialize variables
    10.  
    11. //Check for annoying server hiccup before bothering to make any more variables
    12. var i = 0;
    13. var hiccup=1;
    14. var divs = document.getElementsByTagName('div');
    15.  
    16. for(i=0;i<divs.length;i++) {
    17.     if(divs[i].className=="contentModuleHeader") {
    18.         hiccup=0;
    19.     }
    20. }
    21.  
    22. if(hiccup) {
    23.     document.location.href="http://www.neopets.com/games/nq2/nq2.phtml";
    24. } else {
    25. //begin real battling!!
    26. var useid=-1; // use special item??
    27. var nxactor=1; // who fightsS??' default =1: rohane
    28. var fact=3; // default is attack , will override for low health
    29. var hitTarget = GM_getValue("hitTarget",5); //hittargets 1-4 are reserved for allies
    30. var healingItem = GM_getValue("healingItem",30053); // get the healing item in case HP turns red or yellow
    31. var isHasted = GM_getValue("isHasted",false);
    32. var j=0; // used for looping to find out whose turn is it
    33. var elements = document.getElementsByTagName('img');
    34. for(i=0;i<elements.length;i++)
    35. {
    36.     switch(elements[i].src) {
    37.     case "http://images.neopets.com/nq2/x/com_begin.gif":
    38.         GM_setValue("hitTarget",5);
    39.         GM_setValue("isHasted",false);
    40.         document.location.href="http://www.neopets.com/games/nq2/nq2.phtml?start=1";
    41.         break;
    42.     case "http://images.neopets.com/nq2/x/com_atk.gif":
    43.         var texts = document.getElementsByTagName("font");
    44.         var doMultipleTargets = 0;
    45.         for(j=0;j<texts.length;j++)
    46.         {
    47.             //check to increment target
    48.             if( ( (texts[j].innerHTML.search( /for it has already been defeated!/ ) ) != -1 ) || ( texts[j].innerHTML == "You must select a valid target to cast on!<BR>" ) ) {
    49.                 hitTarget++;
    50.                 if(hitTarget>=9) {
    51.                     GM_setValue("hitTarget",5);
    52.                 } else {
    53.                     GM_setValue("hitTarget",hitTarget);
    54.                 }
    55.             }
    56.            
    57.             //check character's status
    58.             switch( texts[j].innerHTML ) {
    59.             case "<b>Rohane</b>":
    60.                 if( ( texts[j+1].color=="#d0d000" ) || ( texts[j+1].color=="red" ) ) {
    61.                     fact=5;
    62.                     useid = healingItem;
    63.                 }
    64.                
    65.                 break;
    66.             case "<b>Mipsy</b>":
    67.                 nxactor=2;
    68.                 fact=9202; //use group damage
    69.                 if(!isHasted)
    70.                 {
    71.                     fact=9203;
    72.                     GM_setValue("isHasted",true);
    73.                 }
    74.                
    75.                 if( ( texts[j+1].color=="#d0d000" ) || ( texts[j+1].color=="red" ) ) {
    76.                     fact=5;
    77.                     useid = healingItem;
    78.                 }
    79.                
    80.                 break;
    81.             case "<b>Talinia</b>":
    82.                 var multipleTargets = /Multiple Targets/;
    83.                 var k=0;
    84.                 var links = document.getElementsByTagName('a');
    85.                 for( k=0; k<links.length; k++) {
    86.                     if( ( links[k].innerHTML.search( multipleTargets ) ) != -1 ) {
    87.                         fact = 9302;
    88.                     }
    89.                 }
    90.                
    91.                 nxactor=3;
    92.                
    93.                 if( ( texts[j+1].color=="#d0d000" ) || ( texts[j+1].color=="red" ) ) {
    94.                     fact=5;
    95.                     useid = healingItem;
    96.                 }
    97.                
    98.                 break;
    99.             case "<b>Velm</b>":
    100.                 var l=0; // loops to see if velm is wasting his time healing
    101.                 var fullhp = 0; //if its 4 then all 4 people are fully healed
    102.                 var allies = false;
    103.                 //loop through all pictures if it's velm's turn
    104.                 for(l=0;l<elements.length;l++) {
    105.                     //makes sure the script isn't checking enemies hp
    106.                     if(elements[l].src=="http://images.neopets.com/nq2/x/donothing.gif") {
    107.                         allies = true;
    108.                     }
    109.                     //if checking allies HP
    110.                     if(allies) {
    111.                         //is the picture a health bar?
    112.                         if(elements[l].src=="http://images.neopets.com/nq2/x/exp_green.gif") {
    113.                             if(elements[l].width == 45) //45 is full health
    114.                             {
    115.                                 fullhp++;
    116.                             }
    117.                         }
    118.                     }
    119.                 }
    120.                 nxactor=4;
    121.                 fact=9402; // velm heals, trust me you will need this
    122.                 if(fullhp == 4)
    123.                 {
    124.                     fact = GM_getValue("VelmAction",9403);
    125.                 }
    126.                 if((texts[j+1].color=="#d0d000") || (texts[j+1].color=="red"))
    127.                 {
    128.                     fact=5;
    129.                     useid = healingItem;
    130.                 }
    131.  
    132.                 break;
    133.                
    134.             }
    135.         }
    136.         document.location.href="http://www.neopets.com/games/nq2/nq2.phtml?&fact=" + fact + "&target=" + hitTarget + "&use_id=" + useid + "&nxactor=" + nxactor;
    137.         break;
    138.     case "http://images.neopets.com/nq2/x/com_next.gif":
    139.         document.location.href="javascript:setaction(1); document.ff.submit();";
    140.         break;
    141.     case "http://images.neopets.com/nq2/x/com_end.gif":
    142.         document.location.href="javascript:setaction(2); document.ff.submit();";
    143.         break;
    144.     case "http://images.neopets.com/nq2/x/tomap.gif":
    145.         GM_setValue("hitTarget",5);
    146.         GM_setValue("isHasted",false);
    147.         document.location.href="http://www.neopets.com/games/nq2/nq2.phtml?finish=1";
    148.         break;
    149.     case "http://images.neopets.com/nq2/x/nav.gif":
    150.         if(GM_getValue("goLeft"))
    151.         {
    152.             document.location.href="javascript:dosub(3)";
    153.             GM_setValue("goLeft",false);
    154.         }
    155.         else   
    156.         {
    157.             document.location.href="javascript:dosub(4)";
    158.             GM_setValue("goLeft",true);
    159.         }
    160.         break;
    161.     }
    162.  
    163. }
    164. }
    165. window.setTimeout(function() { document.location.href="http://www.neopets.com/games/nq2/nq2.phtml" }, 10000);
    I may have made other modifications to the script (other than the group damage), so I don't know how it'll work out for you. ;)
     
    Heya_old and CoS like this.
  3. CoS

    CoS Level IV

    Joined:
    Jun 16, 2008
    Messages:
    1,090
    Likes Received:
    35
    Will just try it out now!!
    Thanks very much :p


    EDIT: Sorted!! Works a treat thanks very much!! plus rep not tht you need it :p
    I like that i dont have to manually go to the game :D your a genius :p