Пример #1
0
def gotoCity(proc, cityid, wayPointList):
    
    def isClose(x1, y1):
        x, y = dolScript.getSeaPos(proc)
        return dolLib.distance(x1, y1, x, y) <= 10
    
    print 'Go to City %x' % (cityid)

    for x1, y1 in wayPointList:
        x, y = dolScript.getSeaPos(proc)
        log('Going to %d, %d' % (x1, y1))
        log('My pos = %d, %d' % (x, y))
        while(dolLib.distance(x1, y1, x, y) > 5):
            log('---Going to %d, %d' % (x1, y1))
            dolLib.turnPos(proc, x1, y1)
            time.sleep(2)
            
            state = dolScript.getSailState(proc)
            if(state < 4):
                dolCall.sail(proc, 4)
                time.sleep(2)
            
            if(not isClose(x1, y1) and not dolScript.isSceneChange(proc) and not dolScript.isAutoSail(proc) and dolScript.getHP(proc) >= 10):
                dolCall.custom_safe(proc, 1)
                time.sleep(2)
                
            sCount, sList = dolScript.getSkill(proc) 
    
            if(not isClose(x1, y1) and not dolScript.isSceneChange(proc) and sCount != 3 and 75 not in sList): #75 == 警戒
                log("发动警戒技能") 
                dolCall.custom_safe(proc, 3)#f3 警戒
                time.sleep(2)
            
            
            
            if(not isClose(x1, y1) and dolScript.getHPRatio(proc) < 0.4):
                if(not dolScript.isOnline(proc)):
                    break
                    
                hp1 = dolScript.getHP(proc)
                log("要补行动力, 行动力 = %d" % (hp1))
                dountil(dolScript.isNormal, [proc])
                
                dolCall.custom_safe(proc, 7) #f7 要设置为料理
                time.sleep(2)
                hp2 = dolScript.getHP(proc)
                log("吃了一个料理, 行动力 = %d" % (hp2))
                if(hp1 == hp2):
                    time.sleep(5)
                time.sleep(0.2)
            x, y = dolScript.getSeaPos(proc)
            print "Now in (%d, %d), distance to (%d, %d) is %d" % (x,y, x1, y1, dolLib.distance(x1, y1, x, y))
    dolCall.sail(proc, 0)
    dolCall.enterDoor(proc, cityid)
            
        
    
Пример #2
0
def turnPos(proc, x1, y1, e = 5):
    x1 = int(x1)
    y1 = int(y1)
    x,y = dolScript.getSeaPos(proc)
    alpha = dolScript.getAngle(proc)
    
    if(math.fabs(x1 - x) > 8192):
        if(x > x1):
            x = x-16384
        else:
            x = 16384 - x
            
    dis = distance(x1, y1, x, y)
    
    cosa = (x1 - x) / float(dis)
    
    sina = (y1 - y) / float(dis)
    #print 'x = %.3f, x1 = %.3f' % (x, x1)
    #print 'y = %.3f, y1 = %.3f' % (y, y1)
    #print 'alpha = %.3f' % (alpha)
    
    #print "cos = %.3f" % (cosa)
    #print "sin = %.3f" % (sina)
    
    a1 = math.acos(cosa) * 180 / math.pi
    #print a1
    if(sina > 0):
        a1 = 360 - a1
    #print a1
        
    l = math.fabs(a1 - alpha)
    if(l > 180):
        l = 360 - l
    print "degree diff = %.3f" % (l)
    
    if (l > e):
        if(l > 30):
            dolCall.sail(proc, 1)
            time.sleep(1)
        print "Turn to %.3f" % (a1)
        dolCall.turn(proc, a1)
        if(l > 30):
            time.sleep(1)
            dolCall.sail(proc, 4)