12
« on: January 19, 2018, 09:09:08 PM »
battle_lib
//áèáëèîòåêà ôóíêöèé óïðàâëåíèÿ áîåì è ïîèñêà ìîáîâ
$time_move_cursor = 100
//[skills]
$skill_heal_use = INT ( INIREAD ($iniSettings, "skill_heal_use","skills"))
$skill_heal = INT ( INIREAD ($iniSettings, "skill_heal","skills") )
$skill_shield_use = INT ( INIREAD ($iniSettings, "skill_shield_use","skills"))
$skill_shield = INT ( INIREAD ($iniSettings, "skill_shield","skills") )
$skill1_use = INT ( INIREAD ($iniSettings, "skill1_use","skills") )
$skill2_use = INT ( INIREAD ($iniSettings, "skill2_use","skills") )
$skill3_use = INT ( INIREAD ($iniSettings, "skill3_use","skills") )
$skill4_use = INT ( INIREAD ($iniSettings, "skill4_use","skills") )
$skill4_is_area = INT ( INIREAD ($iniSettings, "skill4_is_area","skills") )
$skill5_use = INT ( INIREAD ($iniSettings, "skill5_use","skills") )
$skill6_use = INT ( INIREAD ($iniSettings, "skill6_use","skills") )
//[battle]
$r_find = INT ( INIREAD ($iniSettings, "r_find","battle") )
$find_near = INT ( INIREAD ($iniSettings, "find_near","battle") )
$is_meelee = INT ( INIREAD ($iniSettings, "is_meelee","battle") )
$not_far_as = INT ( INIREAD ($iniSettings, "not_far_as","battle") )
$dy = INT ( INIREAD ($iniSettings, "dy","battle") )
$dx_hp = 20
//-------------------------------------------------------------------
//ïðîâåðêà õï
SUB (check_hp)
GETSCREEN (0,0,200,100)
print ("check hp")
IF_PICTURE_IN (0,0, 200,100, "source/hp_bar_left_up.bmp", -1, 100)
IF (PXL($_return1 + 70 + $dx_hp ,$_return2 + 7) = 6248447 )
$need_heal = 0
INIWRITE($iniFile, "need_heal", 0, STRCONCAT("p",$id_))
ELSE
//íóæåí õèë
print("need heal")
$need_heal = 1
INIWRITE($iniFile, "need_heal", 1, STRCONCAT("p",$id_))
INIWRITE($iniFile, "x", $persX, STRCONCAT("p",$id_))
INIWRITE($iniFile, "y", $persY, STRCONCAT("p",$id_))
END_IF
END_IF
END_SUB
// îáùàÿ ôóíêöèÿ íàæàòèÿ áîåâûõ ñêèëîâ
SUB (skill_pressed,$button)
SWITCH($button)
CASE (1)
KEYPRESS (#1)
CASE (2)
KEYPRESS (#2)
CASE (3)
KEYPRESS (#3)
CASE (4)
KEYPRESS (#4)
CASE (5)
KEYPRESS (#5)
CASE (6)
KEYPRESS (#6)
END_SWITCH
END_SUB
// õèë â ñåáÿ
SUB (heal_self)
get_pers_pos_map()
skill_pressed($skill_heal)
waitms(200)
//DBLCLICK ($screenX,$screenY)
LCLICK ($screenX,$screenY)
print("heal self")
waitms(1000)
END_SUB
SUB (heal_friend,$frx,$fry)
skill_pressed($skill_heal)
waitms(100)
get_pers_pos_map()
$friendScreenX = ($frx - $persX)*$step + $screenX
$friendScreenY = ($fry - $persY)*$step + $screenY
LCLICK ($friendScreenX,$friendScreenY)
waitms(700)
LCLICK ($friendScreenX,$friendScreenY)
print("heal friend: ",$frx,",",$fry)
waitms(800)
END_SUB
// ùèò â ñåáÿ
SUB (shield_self)
get_pers_pos_map()
skill_pressed($skill_shield)
waitms(200)
//DBLCLICK ($screenX,$screenY)
LCLICK ($screenX,$screenY)
print("shield self")
waitms(300)
END_SUB
SUB (shield_friend,$frx,$fry)
skill_pressed($skill_shield)
waitms(100)
get_pers_pos_map()
$friendScreenX = ($frx - $persX)*$step + $screenX
$friendScreenY = ($fry - $persY)*$step + $screenY
LCLICK ($friendScreenX,$friendScreenY)
waitms(700)
LCLICK ($friendScreenX,$friendScreenY)
print("shield friend: ",$frx,",",$fry)
waitms(800)
END_SUB
// ïîèñê ìîáà
SUB(find_fast)
print("fast scan started")
$minX = 0
$minY = 0
$mobFound = 0
GETSCREEN
DEFINE ($allMobPosArr)
GETFILELIST ($arr, "mobs/*.bmp")
FOR ($a=0,$a< ARRSIZE ($arr))
SCANPICTURE ( $ARR_SCAN, 0,0, $_xmax,$_ymax, STRCONCAT ("mobs/",$arr[$a]), -1, 100)
$ARR_NUM = 0
WHILE ( $ARR_NUM < ARRSIZE ( $ARR_SCAN))
$X = $ARR_SCAN [ $ARR_NUM ]
INC ( $ARR_NUM ,1 )
$Y = $ARR_SCAN [$ARR_NUM]
INC ( $ARR_NUM,1)
ARRPUSH ( $allMobPosArr, $X)
ARRPUSH ( $allMobPosArr, $Y)
END_CYC
UNDEFINE ( $ARR_SCAN)
END_CYC
IF(ARRSIZE($allMobPosArr) > 2)
$mobX = $allMobPosArr[1]
$mobY = $allMobPosArr[2] +$dy
END_IF
//îïðåäåëÿåì áëèæàéøåãî
IF($find_near = 1)
get_pers_pos_map()
$minDist = 9999
$a = 1
WHILE($a<ARRSIZE($allMobPosArr))
$dist = DIST ($screenX, $screenY, $allMobPosArr[$a], $allMobPosArr[$a+1])
IF ($dist < $minDist)
$minDist = $dist
$pairNum = $a
END_IF
INC($a,2)
END_CYC
IF(ARRSIZE($allMobPosArr) > 2)
$minX = $allMobPosArr[$pairNum]
$minY = $allMobPosArr[$pairNum+1]
print("nearest mob: ",$minX,",",$minY)
END_IF
$mobX = $minX
$mobY = $minY +$dy
UNDEFINE($allMobPosArr)
END_IF
IF ($mobX > 0 & $mobY > (0 +$dy) & ($dist/$step) < $not_far_as)
$mobFound = 1
print("mobFound: ",$mobX,",",$mobY)
ELSE
$mobFound = 0
print("no mob found")
END_IF
END_SUB
SUB(find_sword_or_hand)
//èùåì ìå÷ èëè ðóêó
WAITMS($time_move_cursor)
//$tstart = $_ms
$mobFound = 0
GETSCREEN($screenX-$r_find*$step,$screenY-$r_find*$step,$screenX+$r_find*$step,$screenY+$r_find*$step)
IF_PICTURE_IN ($screenX-($cur_r+1)*$step,$screenY-($cur_r+1)*$step,$screenX+($cur_r+1)*$step,$screenY+($cur_r+1)*$step, "source/sword.bmp", -1, 100)
print("need attack")
$mobX = $_return1 - $offsetX
$mobY = $_return2 - $offsetY
$mobFound = 1
$time = 0
END_IF
IF_PICTURE_IN ($screenX-($cur_r+1)*$step,$screenY-($cur_r+1)*$step,$screenX+($cur_r+1)*$step,$screenY+($cur_r+1)*$step, "source/hand.bmp", -1, 100)
print("need get drop")
$mobX = $_return1 - $offsetX
$mobY = $_return2 - $offsetY
$mobFound = 2
$time = 0
END_IF
//$time = $_ms + $time_move_cursor
//WHILE($time > $_ms)
//END_CYC
//$tend = $_ms
//print("time: ",$tend-$tstart)
END_SUB
SUB(slow_scan)
//ðàñêðó÷èâàåì êóðñîð âîêðóã ïåðñà
//â çàâèñèìîñòè îò ìå÷à èëè ðóêè àòàêóåì èëè ïîäíèìàåì äðîï
print("slow_scan started")
//ïðîâåðèì áûëè ëè íàæàòû è íåèñïîëüçîâàíû ñêèëû
GETSCREEN
//IF (PXL(367,457) = 2590663)
IF (PXL(367,431 + $offsetY) = 2590663)
skill_pressed($last_skill)
print("skill pressed detected")
END_IF
get_pers_pos_map()
//ñòàâèì êóðñîð íà ïåðñà
LCLICK($screenX,$screenY)
WAITMS(100)
//ïðîâåðÿåì îòîáðàæåíèå êóðñîðà
find_sword_or_hand()
$cur_r = 1
IF($mobFound = 0)
//åñëè íå íàøëè ìîáà, òî íà÷èíàåì ðàñêðó÷èâàòü ñïèðàëü
WHILE ($cur_r <= $r_find)
//up
IF($mobFound = 0)
KEYPRESS(#UP)
find_sword_or_hand()
END_IF
//right
IF($mobFound = 0)
$a = 0
WHILE($a<$cur_r)
KEYPRESS(#RIGHT)
find_sword_or_hand()
IF($mobFound > 0)
$a = $cur_r
END_IF
INC($a,1)
END_CYC
END_IF
//down
IF($mobFound = 0)
$a = 0
WHILE($a<$cur_r*2)
KEYPRESS(#DOWN)
find_sword_or_hand()
IF($mobFound > 0)
$a = $cur_r*2
END_IF
INC($a,1)
END_CYC
END_IF
//left
IF($mobFound = 0)
$a = 0
WHILE($a<$cur_r*2)
KEYPRESS(#LEFT)
find_sword_or_hand()
IF($mobFound > 0)
$a = $cur_r*2
END_IF
INC($a,1)
END_CYC
END_IF
//up
IF($mobFound = 0)
$a = 0
WHILE($a<$cur_r*2)
KEYPRESS(#UP)
find_sword_or_hand()
IF($mobFound > 0)
$a = $cur_r*2
END_IF
INC($a,1)
END_CYC
END_IF
//right
IF($mobFound = 0)
$a = 0
WHILE($a<$cur_r)
KEYPRESS(#RIGHT)
find_sword_or_hand()
IF($mobFound > 0)
$a = $cur_r
END_IF
INC($a,1)
END_CYC
END_IF
INC($cur_r,1)
END_CYC
END_IF
END_SUB
SUB(find_mob)
slow_scan()
IF($mobFound = 0 & $mode_ = 0)
find_fast()
END_IF
END_SUB
// àòàêà ìîáà
SUB(attack_mob)
print("attack mob: ",$mobX,",",$mobY)
$mapMobX = $persX + INT (( $mobX - $screenX)/$step)
$mapMobY = $persY + INT (( $mobY - $screenY)/$step)
set_command(2, $mapMobX, $mapMobY )
$time_to_mob = INT(DIST($mobX,$mobY,$screenX,$screenY) *10)
IF ($time_to_mob > 600)
DBLCLICK($mobX,$mobY)
ELSE
LCLICK($mobX,$mobY)
//òóò ìîæåò âûñêîñ÷èòü ïîïàï âûáîðà öåëè
WAITMS(600)
LCLICK($mobX,$mobY)
END_IF
print("time to mob: ",$time_to_mob)
WAITMS($time_to_mob)
IF($skill1_use = 1)
skill_pressed(1)
$last_skill = 1
WAITMS(100)
END_IF
//find_sword_or_hand()
IF($skill2_use = 1 & $mobFound > 0)
skill_pressed(2)
$last_skill = 2
WAITMS(100)
END_IF
//find_sword_or_hand()
IF($skill3_use = 1 & $mobFound > 0)
skill_pressed(3)
$last_skill = 3
WAITMS(100)
END_IF
//find_sword_or_hand()
IF($skill4_use = 1 & $mobFound > 0)
skill_pressed(4)
$last_skill = 4
IF($skill4_is_area = 1)
WAITMS(100)
KEYPRESS(#ENTER)
WAITMS(300)
DBLCLICK($mobX,$mobY)
END_IF
WAITMS(100)
END_IF
//find_sword_or_hand()
IF($skill5_use = 1 & $mobFound > 0)
skill_pressed(5)
$last_skill = 5
WAITMS(100)
END_IF
//find_sword_or_hand()
IF($skill6_use = 1 & $mobFound > 0)
skill_pressed(6)
$last_skill = 6
WAITMS(100)
END_IF
//WAITMS(2000)
END_SUB
// ñáîð ëóòà
SUB(get_drop)
print("drop loot: ",$mobX,",",$mobY)
$mapMobX = $persX + INT (( $mobX - $screenX)/$step)
$mapMobY = $persY + INT (( $mobY - $screenY)/$step)
set_command(3, $mapMobX, $mapMobY )
LCLICK($mobX,$mobY)
WAITMS($time_to_mob)
//ïîâåøó íàæàòèå íà ñîáðàòü âñå íà ïîòîê îáðàáîòêè âñïëûâàþùèõ îêîí
//KEYPRESS(#ENTER)
WAITMS(1000)
END_SUB
SUB(return_to_start)
//ýòà ôóíêöèÿ äîëæíà âåðíóòü ïåðñîíàæà íà ìåñòî ñòàðòà
//êîîðäèíàòû ñòàðòà â ãëîáàëüíûõ øàãàõ
//âèäèìûé ýêðàí èìååò 15*9 öåëûõ øàãîâ
$try = 3
get_pers_pos_map()
print("return to start point: ",$startX,",",$startY)
print("current pos: ",$persX,",",$persY)
WHILE((($persX != $startX) | ($persY != $startY)) & $try > 0)
IF(ABS($startX - $persX) < 7)
$dx_step = $startX - $persX
ELSE
$delta = $startX - $persX
$dx_step = INT((($delta)/ABS($delta))*6) +RNDFROM(-2,1,0,1)
END_IF
IF(ABS($startY - $persY) < 4)
$dy_step = $startY - $persY
ELSE
$delta = $startY - $persY
$dy_step = INT((($delta)/ABS($delta))*3) +RNDFROM(-2,1,0,1)
END_IF
LCLICK($screenX + $dx_step*$step,$screenY + $dy_step*$step)
WAITMS(INT(DIST(0,0,$dx_step,$dy_step)*10*$step))
INC($try,-1)
get_pers_pos_map()
set_command(1,$persX,$persY)
END_CYC
END_SUB
SUB(follow,$fx,$fy)
$startX = $fx
$startY = $fy
return_to_start()
END_SUB
SUB(check_command)
$com_ = INT(INIREAD($iniFile, "com","command"))
$x_ = INT(INIREAD($iniFile, "x","command"))
$y_ = INT(INIREAD($iniFile, "y","command"))
print("check command: ",$com_," ",$x_," ",$y_)
SWITCH($com_)
CASE(1)
// follow me
print("follow me: ",$x_,",",$y_)
follow($x_,$y_)
CASE(2)
// attack mob
print("attack mob at: ",$x_,",",$y_)
follow($x_,$y_)
find_mob()
IF($mobFound = 0)
//äåéñòâè¤ â ñëó÷àå îòñóòñòâè¤ ìîáà
return_to_start()
END_IF
IF ($mobFound = 1)
attack_mob()
END_IF
IF ($mobFound = 2)
get_drop()
END_IF
CASE(3)
// get drop
print("get drop at: ",$x_,",",$y_)
follow($x_,$y_)
find_mob()
IF($mobFound = 0)
//äåéñòâè¤ â ñëó÷àå îòñóòñòâè¤ ìîáà
return_to_start()
END_IF
IF ($mobFound = 1)
attack_mob()
END_IF
IF ($mobFound = 2)
get_drop()
END_IF
CASE(4)
// check party need_heal
DEFAULT
// idle
END_SWITCH
END_SUB
SUB(check_heal_friend)
//ñìîòðèì ïî âñåì ÷ëåíàì ïàòè, èùåì need_heal = 1 è êîîðäèíàòû
$need_heal_friend = 0
FOR ($a=0,$a < 5)
IF($a != $id_) // íå õèëèì òàêèì îáðàçîì ñàìè ñåáÿ
IF(INT(INIREAD($iniFile, "need_heal",STRCONCAT("p",$a))))
$friend_healX = INT(INIREAD($iniFile, "x",STRCONCAT("p",$a)))
$friend_healY = INT(INIREAD($iniFile, "y",STRCONCAT("p",$a)))
$need_heal_friend = 1
print("need heal friend")
//áåðåì ïåðâîãî ïîïàâøåãîñÿ è âûõîäèì
//GOTO(end_check_heal_friend)
END_IF
END_IF
END_CYC
//end_check_heal_friend:
END_SUB