|
 
- 帖子
- 98
- 精华
- 0
- 幽灵币
- 0
- 体力值
- 4886
- 游戏阵营
-
- 我的目标
-
- 注册时间
- 2009-10-19
|
6#
发表于 2010-7-15 21:23
| 只看该作者
这个是开箱子一起的- // 这个脚本在网页幽灵里运行可能会出错,用彗星开发小助手运行吧
- // 要是网络卡了也会出错,如果不太卡或许还可以自动恢复
- // 机器太卡可能也会出错,具体不清楚
- // 背包没药了也会出错
- // 出错的定义是3分钟以内没有任何动作,或者动作是无效的死循环
- // 最好不要在大地图或者奇奇怪怪的地方上运行脚本
- // 如果在打怪界面按开始,就会只打同一个怪(刷怪)
- // 如果在一个地图内停留了指定的时间,会被脚本认为是出错了,脚本会尽可能的处理掉
- // 如果想要自动买药,最好先跑去打开商店页面再运行,但不能保证一定会成功,别太依赖此功能
- // 就算是停止状态,寻路功能还是会使用脚本里的,这样比较方便(比如手动做任务,找NPC等)
- // ie崩溃无法处理
- var WAITTIME=10; // 服务器忙,请3秒钟以后再试!
- var ERROR_TIME = 30; // 出错了!怎么都不换地图啊,过段时间处理
- var limitHP = 8000; // 当血量小于这个数值就加血(满血不加),自己根据情况修改
- var onlyAddHPThisHero = ""; // 只为这个人加血,根据个人情况修改,不填为全加
- var lag = 5; // 延时,秒,完全加载网页所需时间,太小或太卡就会不停的刷新
- var upPathLag = 1.3; // 过图延时,秒,好像过图太快会被踢
- var noClickFinish = 0; // 如果=1,那就只打怪不按完成。可以自己换上小家将再按,家将比较容易升级
- var wrongTime; // WAITTIME
- var keepAttack;
- var lastCity;
- var worldMapId;
- var lastMonsterURL;
- var needKillNum;
- var targetType = ''; // unknown,monster,ncp,map @ ''=unknown
- var stopsign;
- var isInit;
- init(); // ---大家都去打残卷啊!
- function stop(){
- stopsign=1;
- document.title="STOP";
- if(document.frames[0].document.frames[0].atkNeedTime!=undefined)
- document.frames[0].document.frames[0].location.href ='enter-cityImpl.action';
- }
- function start(){
- stopsign=0;
- checkEnvironment();
- autoScouringFinish();
- if(keepAttack) document.title="刷怪";
- else document.title="平叛";
- }
- function init(){
- if(isInit) return;
- isInit=1;
- stopsign=1;
- needKillNum=10;
- wrongTime = 0;
- errTime = ERROR_TIME;
- lastCity = "";
- // createButton();
- setInterval("loopFun()",1000);
- }
- function createButton(){
- document.body.scroll="yes";
- var sobj = createIfr("222");
- var ifram = document.frames("222");
- ifram.document.write("<body><table align='center'>");
- ifram.document.write("<input type='radio' name='radiobutton' onclick='parent.start()'> 开始");
- ifram.document.write("<input type='radio' name='radiobutton' onclick='parent.stop()' > 停止");
- ifram.document.write("</table></body>");
- }
- function loopFun(){
- try{checkError()}catch(e){};
- try{myErrorHandler()}catch(e){};
- try{autoAttack()}catch(e){};
- try{document.frames[0].document.frames[0].eval(pickUpPath+'')}catch(e){};
- }
- function autoAttack(){
- if(stopsign)
- return;
- var ifr = document.frames[0].document.frames[0];
- if(!ifr.codes)
- return;
- lastMonsterURL = ifr.location.href;
- if(ifr.atkNeedTime==undefined)
- {
- ifr.atkNeedTime = ifr.codes.length+3;
- if(ifr.codes[ifr.codes.length-2].targetTeamId>0) ifr.isFail=1;
- else ifr.isFail=0;
- primaryFrame.loadPlayer(1);
- ifr.eval("function setTimeout(){}");
- ifr.eval(LoadJS+'');
- ifr.eval("LoadJS('js/application.js')");
- }
- ifr.atkNeedTime--;
- alert("打怪: "+needKillNum+"</br>时间: "+ifr.atkNeedTime);
- if(ifr.atkNeedTime>0) return;
- var goOut = 0;
- needKillNum -= getMonsterNum();
- if(!keepAttack && needKillNum<=0)
- goOut=1;
- if(ifr.isFail)
- goOut=1;
- if(!goOut && addHP())
- {
- needKillNum += getMonsterNum();
- return;
- }
- ifr.atkNeedTime=9999999; // 破坏进入条件
- if(goOut)
- {
- ifr.inCity=1;ifr.codes=0;
- ifr.mapHTML=httpPost("enter-cityImpl.action");
- autoScouringFinish();
- return;
- }
- ifr.location.reload();
- // alert("本轮平叛还有"+needKillNum+"个怪");
- return;
- }
- function getMonsterNum(){
- try
- {
- var ifr = document.frames[0].document.frames[0];
- if(!ifr.codes)
- return 0;
- var min=1;
- for(var i=0;i<ifr.codes.length;++i)
- {
- if(ifr.codes[i].targetTeamId < min)
- min = ifr.codes[i].targetTeamId;
- }
- return min*(-1)+1;
- }
- catch(e)
- {
- return 999;
- }
- }
- function autoScouringFinish(){
- try
- {
- if(stopsign)
- return;
- if(keepAttack)
- return;
- var ifr = document.frames[0].document.frames[0];
- if(!ifr.inCity||addHP())
- {
- setTimeout("autoScouringFinish()",lag*500);
- return;
- }
-
- if(isHaveErrorPage())
- {
- setTimeout("autoScouringFinish()",lag*500);
- return;
- }
- offAlert();
- ifr = getInfoIfr();
- if(!ifr)
- {
- document.frames[0].showScouringTask();
- setTimeout("autoScouringFinish()",lag*500);
- return;
- }
- else if(ifr.location.href.indexOf("manageScouringTask")==-1)
- {
- ifr.location.href = 'manageScouringTask.action';
- setTimeout("autoScouringFinish()",lag*500);
- return;
- }
- if(ifr.$('span').length==0)
- {
- setTimeout("autoScouringFinish()",lag*500);
- return;
- }
- if(!noClickFinish) ifr.$('span.finished_button').click();
- nextScour();
- return;
- }
- catch(e)
- {
- }
- }
- function nextScour(){
- try
- {
- if(stopsign)
- return;
- var ifr = document.frames[0].document.frames[0];
- if(isHaveErrorPage())
- {
- setTimeout("nextScour()",lag*500);
- return;
- }
- var ifr = document.frames[0].document.frames[0];
-
- var myObjs = getInfoIfr().document.getElementsByTagName("SPAN");
-
- var monLv = 99999;
- var monsterId = null;
- for(var i=0;i<myObjs.length;++i)
- {
- if(myObjs[i].className=='monster')
- {
- var strs = myObjs[i+2].innerText.match(/(\d+).(\d+)/);
- needKillNum=strs[2]-strs[1];
- if(needKillNum==0) continue;
- if(myObjs[i].monsterSce == getMapTitle())
- {
- ifr.location.href = "battle-attackMonster.action?sceneId="+getRealSceId(myObjs[i].monsterId);
- return;
- }
- var curLv = eval(myObjs[i].monsterLV);
- if(curLv < monLv)
- {
- monsterId = myObjs[i].monsterId;
- monLv = curLv;
- }
- }
- }
- if(!monsterId) return;
- targetType='monster';
- myPickUpPath(monsterId);
- }
- catch(e)
- {
- }
- }
- function addHP(){
- try
- {
- offAlert();
- var errorHandlerFunc = function (errMsg){
- if(errMsg.match(/没有金创药/)) buyGoods(60300092,50);
- alert(errMsg);
- };
- var ifr = document.frames[0].document.frames[0];
- var playerObj = primaryFrame.loadPlayer();
- var heroObjs = [];
- heroObjs.push(playerObj.userProxy);
- for(var i=0;i<playerObj.heroList.length;++i)
- {
- if(playerObj.heroList[i].isEquip==1)
- heroObjs.push(playerObj.heroList[i]);
- }
-
- for(i=0;i<heroObjs.length;++i)
- {
- if(heroObjs[i].curHP>limitHP)
- continue;
- if(onlyAddHPThisHero && heroObjs[i].entName!=onlyAddHPThisHero && heroObjs[i].curHP!=0)
- continue;
- if(heroObjs[i].curHP>=heroObjs[i].HP)
- continue;
- var ifr = document.frames[0].document.frames[0];
- ifr.dwrAction.fullHeroHp(heroObjs[i].heroId,{errorHandler:errorHandlerFunc});
- return 1;
- }
- }
- catch(e)
- {
- }
- return 0;
- }
- function continueAttack(){
- if(addHP())
- setTimeout("continueAttack()",lag*500);
- else if(lastMonsterURL)
- document.frames[0].document.frames[0].location.href=lastMonsterURL;
- }
- function myErrorHandler(){
- if(stopsign) return;
- var ifr = document.frames[0].document.frames[0];
- if(ifr.codes) retrun;
- if(ifr.bomb==undefined) ifr.bomb=ERROR_TIME;
- if(--ifr.bomb>0) return;
- ifr.bomb=ERROR_TIME;
- ifr.location.href="enter-cityImpl.action";
- if(keepAttack)
- setTimeout("continueAttack()",lag*2000);
- else
- setTimeout("autoScouringFinish()",lag*2000);
- }
- function checkError(){
- if(stopsign)
- return;
- var errIfr = isHaveErrorPage();
- if(!errIfr)
- {
- wrongTime = WAITTIME;
- retrun ;
- }
- wrongTime--;
- if(wrongTime>0)
- return;
- wrongTime = WAITTIME;
- errIfr.parent.location.reload();
- }
- function isHaveErrorPage(ifr){
- try
- {
- if(!ifr)
- ifr = top;
- if(ifr.location.href.indexOf("appError.jsp")!=-1)
- return ifr;
- var errPageIfr = null;
- for(var i=0; !errPageIfr&&i<ifr.document.frames.length; ++i)
- errPageIfr = isHaveErrorPage(ifr.document.frames[i]);
- return errPageIfr;
- }
- catch(e)
- {
- return null;
- }
- }
- function checkEnvironment(){
- var ifr = document.frames[0].document.frames[0];
- if(ifr.location.href.indexOf("sceneId=")!=-1)
- keepAttack = 1;
- else
- keepAttack = 0;
- }
- function getMapTitle(){
- var ifr = document.frames[0].document.frames[0];
- return ifr.document.title;
- }
- function offAlert(){
- var ifr = document.frames[0].document.frames[0];
- var str = "function alert(A){top.alert(A)}";
- ifr.eval(str);
- }
- /*修改信息显示位置*/
- function alert(A){
- // primaryFrame.document.forms[0].chatText.innerText=A+''; //聊天处显示
- // var obj = primaryFrame.gongneng_right_button_wrapper; //right_button_wrapper商城处显示
- var obj = primaryFrame.gongneng_qian; //qian银子处显示
- obj.style.background="#000000";
- obj.style.color="#FBF582";
- obj.style.fontSize=14;
- obj.innerHTML=A+'';
- }
- function myPickUpPath(sceid){
- document.frames[0].document.frames[0].eval(pickUpPath+'');
- document.frames[0].document.frames[0].pickUpPath(0,sceid,0);
- }
- function pickUpPath(curCasId, sceId, pickUpPathType) {
- parent.pathList = [];
- parent.isPickUpPath = false;
- dwrAction.pickUpPath(curCasId, sceId, pickUpPathType, {
- callback:function(data) {
- if(!data) return;
- if(pickUpPathType == 0)
- data.push(sceId);
- if(top.stopsign)
- top.targetType='';
- data.shift();
- top.gotoThis(data);
- },
- errorHandler:top.alert
- });
- }
- function gotoThis(sceneData){
- if(!sceneData.length) return;
- var ifr = document.frames[0].document.frames[0];
- var sceId = sceneData.shift();
- if(!("targetType" in top)) targetType='';
- if(targetType) targetType = targetType.toLowerCase();
- else targetType = 'unknown';
- var realSceId,url;
- realSceId=getRealSceId(sceId);
- var worldMapIdx=-1;
- for(var i=0;i<sceneData.length;++i) // 找大地图
- {
- if(!worldMapId) break; // 如果大地图的真实ID还没有获得,那就不用找了
- if(sceneData[i]%10000==181)
- {
- worldMapIdx=i;
- break;
- }
- }
- for(var i=0;i<=worldMapIdx;++i) // 如果找到大地图,下次从第一层地图开始,并把本次要过的图改为大地图
- {
- sceneData.shift();
- realSceId=worldMapId;
- }
- if(!realSceId)
- {
- upPathErrorHandler(sceId);
- return;
- }
- url = 'transport.action?targetCasId=' + ifr.wrwte(realSceId);
- if(sceneData.length) // 不是最后一个是目标,那就过图
- {
- if(!worldMapId && sceId%10000==181) worldMapId=realSceId; // 首次获得大地图ID
- ifr.mapHTML=httpPost(url);
- setTimeout(function (){gotoThis(sceneData)},upPathLag*1000);
- return;
- }
- // 处理最后一个目标
- if(targetType == 'monster')
- ifr.location.href = 'battle-attackMonster.action?sceneId=' + realSceId;
- if(targetType == 'npc')
- {
- httpPost('enter-npc.action?sceId=' + realSceId);
- setTimeout("enteredNPC()",1000);
- }
- if(targetType == 'unknown')
- {
- document.frames[0].eval("pathList[pathIndex+1]="+sceId);
- document.frames[0].isPickUpPath=true;
- document.frames[0].document.frames[0].location.reload();
- }
- if(targetType == 'map')
- {
- httpPost(url);
- document.frames[0].document.frames[0].location.reload();
- }
- }
- function getRealSceId(sceId){
- return sceId+'';
- }
- function upPathErrorHandler(sceId)
- {
- document.frames[0].document.frames[0].location.href="enter-cityImpl.action";
- }
- function httpPost(urls)
- {
- oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
- oXmlHttp.open("POST",urls,false);
- oXmlHttp.setRequestHeader("cache-control","no-cache");
- oXmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
- oXmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
- oXmlHttp.send(null);
- return oXmlHttp.responseText;
- }
- function buyGoods(goodsId,num){
- var ifr = document.frames[0].document.frames[0];
- ifr.dwrAction.buyItemFromStoreImpl(10023,goodsId,num);
- }
- function getInfoIfr()
- {
- var ifr = document.frames[0].document.frames[0];
- for(var i=0;i<10;++i)try{if(ifr.document.frames[i].$)return ifr.document.frames[i]}catch(e){};
- return null;
- }
- function createIfr(id_str){
- if(!id_str)
- id_str='myifr';
- if(typeof(id_str)!='string') return false;
- if(document.getElementById(id_str)) return document.getElementById(id_str);
- var obj = document.createElement("iframe");
- obj.id = id_str;
- obj.width=220;
- return document.body.appendChild(obj);
- }
- function LoadJS(file){
- var head = document.getElementsByTagName('HEAD').item(0);
- var script = document.createElement('SCRIPT');
- script.src = file;
- script.type = "text/javascript";
- head.appendChild(script);
- }
- //=====================以下为循环捡箱========================
- function openBoxes(objName){
- this._main=document.frames[0];
- this._primary=document.frames[0].document.frames[0];
- this.config={
- loopDelay:1800000, //大循环间隔
- smallLoopDelay:600, //小循环间隔
- boxFrameName:'getBox' //frame名
- };
- this.stopFlag=0;//0-非结束;1-结束
- this._boxIds=[240112,240211,140110,140207,280109,280213,70106,70204,200104,200206,200305,300109,300502,300207,300308];
- this.delayLoop=null;
- this.index=0;
- this.obj=objName;
- }
- openBoxes.prototype.toString=function(){
- var str = '';
- str+="<body style='background-color:transparent;background:url(http://imageRes02.youxigu.com/sword/image/pages/mainFrame/dabeijing.gif);text-align:center;'><table border=1><tr>";
- str+="<th style='color:red;' colspan='2' id= 'tips_click_box'>平叛开箱</th></tr>";
- str+="<tr><td><input type='button' style='CURSOR: hand' onclick='parent."+this.obj+".beginO()' value='开箱'/></td>";
- str+="<td><input type='button' style='CURSOR: hand' onclick='parent."+this.obj+".stopO()' value='停开'/></td>";
- str+="<tr><td><input type='button' style='CURSOR: hand' onclick='parent.start()' value='平叛'/></td>";
- str+="<td><input type='button' style='CURSOR: hand' onclick='parent.stop()' value='停止'/></td></tr>";
- // str+="<tr><th style='color:red;' colspan='2'>加血<input type='text' size='4' value='10000' onchange='this.value=top.limitHP=this.value-0'></th></tr>";
- str+="</tr></table></body>";
- return str;
- }
- openBoxes.prototype.appendElement=function(id,type,height,width){
- if(!id) id=this.obj+"_"+type;
- if(typeof(id)!='string') id+='';
- this.config.boxFrameName=id;
- if(document.getElementById(id)) return document.getElementById(id);
- var anElement = document.createElement(type);
- anElement.id = id;
- anElement.width=width;
- anElement.height=height;
- return document.body.appendChild(anElement);
- }
- openBoxes.prototype.showMessage=function(msg){
- var targetObj = primaryFrame.gongneng_qian;
- targetObj.style.color="#FBF582";
- targetObj.style.background="#000000";
- targetObj.style.fontSize=12;
- targetObj.innerHTML=msg;
- }
- openBoxes.prototype.showMsg=function(msg){
- document.frames(this.config.boxFrameName).document.all.tips_click_box.innerHTML = msg;
- }
- openBoxes.prototype.hookAlert=function(){
- this._main.showAlert=this.showMessage;
- this._main.alert=this.showMessage;
- this._primary.alert=this.showMessage;
- this._primary.showAlert=this.showMessage;
- }
- openBoxes.prototype.getSysTime=function(){
- return (new Date()).toLocaleTimeString();
- }
- openBoxes.prototype.getBoxObj=function(sceId){
- var str = "<div class='funName' funId='172' sceId="+sceId+" onclick='getBoxThings(this)'></div>"
- var thisObj = primaryFrame.$(str).get(0);
- return thisObj;
- }
- openBoxes.prototype.beginO=function(){
- this.hookAlert();
- this.index=0;
- this.stopFlag=0;
- try{clearTimeout(this.delayLoop);}catch(e){};
- this.boxCPU();
- }
- openBoxes.prototype.stopO=function(){
- this.stopFlag=1;
- try{clearTimeout(this.delayLoop);}catch(e){};
- }
- openBoxes.prototype.boxCPU=function(){
- if(this.stopFlag) return;
- if(this.index>=this._boxIds.length){
- this.showMsg("End At "+this.getSysTime());
- this.index=0;
- this.delayLoop=setTimeout(""+this.obj+".boxCPU()",this.config.loopDelay);
- return;
- }
- var obj=this.getBoxObj(this._boxIds[this.index]);
- this._getBoxThings(obj);
- }
- openBoxes.prototype._getBoxThings=function(obj){
- this.hookAlert();
- this.index++;
- this._main.getBoxThings(obj);
- setTimeout(""+this.obj+".boxCPU()",this.config.smallLoopDelay);
- this.showMsg("Now At "+this.index);
- }
- //Main
- //运行该脚本;然后再运行别的脚本
- var oBox = new openBoxes("oBox");
- if(document.body.scroll=='no') document.body.scroll='yes';
- //可以这样设置循环间隔:
- //oBox.config.loopDelay=3600*1000;
- //oBox.config.smallLoopDelay=500;
- var obj = oBox.appendElement('getBox','iframe',160,180);
- document.frames("getBox").document.write(oBox);
复制代码 |
-
1
评分次数
-
|