LearningRO Posted December 11, 2018 Group: Members Topic Count: 107 Topics Per Day: 0.02 Content Count: 778 Reputation: 73 Joined: 02/10/12 Last Seen: Yesterday at 12:42 AM Share Posted December 11, 2018 hi, all how to make new function when call the function character auto random walk ? and this function will be used on usable item? Quote Link to comment Share on other sites More sharing options...
0 n0tttt Posted December 12, 2018 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 303 Reputation: 118 Joined: 12/10/16 Last Seen: Friday at 02:39 AM Share Posted December 12, 2018 function script random_walk { if(@walking) { @walking = false; } else { @walking = true; while(@walking) { getmapxy .@m$,.@x,.@y,UNITTYPE_PC; getfreecell .@m$,.@to_x,.@to_y,.@x,.@y,10,10,3; unitwalk getcharid(3),.@to_x,.@to_y; while(.@x != .@to_x || .@y != .@to_y) sleep2 500; } } return; } Not tested. Usage: callfunc "random_walk"; If you want to end the function just call it again. Quote Link to comment Share on other sites More sharing options...
0 LearningRO Posted December 15, 2018 Group: Members Topic Count: 107 Topics Per Day: 0.02 Content Count: 778 Reputation: 73 Joined: 02/10/12 Last Seen: Yesterday at 12:42 AM Author Share Posted December 15, 2018 On 12/12/2018 at 8:44 AM, n0tttt said: function script random_walk { if(@walking) { @walking = false; } else { @walking = true; while(@walking) { getmapxy .@m$,.@x,.@y,UNITTYPE_PC; getfreecell .@m$,.@to_x,.@to_y,.@x,.@y,10,10,3; unitwalk getcharid(3),.@to_x,.@to_y; while(.@x != .@to_x || .@y != .@to_y) sleep2 500; } } return; } Not tested. Usage: callfunc "random_walk"; If you want to end the function just call it again. Quote [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Debug]: map_search_freecell: Incorrect usage! When src is NULL, flag has to be &1 and can't have &2 [Error]: script:run_script_main: infinity loop ! [Debug]: Source (NPC): FAKE_NPC (invisible/not on a map) i got error like that Quote Link to comment Share on other sites More sharing options...
0 LearningRO Posted December 15, 2018 Group: Members Topic Count: 107 Topics Per Day: 0.02 Content Count: 778 Reputation: 73 Joined: 02/10/12 Last Seen: Yesterday at 12:42 AM Author Share Posted December 15, 2018 btw i found this is similiar what i want function script F_botex { set .@i,0; while (.@i < 1) { set .@b,0; dispbottom .@i+""; .@rid = getcharid(3); getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; .@x = rand(-13,13)+.@x0; .@y = rand(-13,13)+.@y0; sleep2 100; if(!checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate not exists!"; continue; } else if(checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate exists!"; } sleep2 100; while(.@x0 != .@x && .@y0 != .@y) { set .@b,.@b+1; viewpoint 1,.@x,.@y,1,0xFF0000; dispbottom "auto walking to x = "+.@x+" y = "+.@y; unitwalk getcharid(3),.@x,.@y,strnpcinfo(3)+"::OnReach"; sleep2 2000; if(.@b > 5) break; getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; } unitskilluseid .@rid,"WL_JACKFROST",5,.@rid,-4; percentheal 100,100; sleep2 100; dispbottom "JackJack"; } end; } btw is possible change function "unitskilluseid" to "unitattack" ? the purpose like auto attack but via script Quote Link to comment Share on other sites More sharing options...
0 n0tttt Posted December 20, 2018 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 303 Reputation: 118 Joined: 12/10/16 Last Seen: Friday at 02:39 AM Share Posted December 20, 2018 function script random_walk { @walking = !@walking; if(@walking) { while(@walking) { getmapxy .@m$,.@x,.@y,UNITTYPE_PC; getfreecell .@m$,.@to_x,.@to_y,.@x,.@y,10,10; unitwalk getcharid(3),.@to_x,.@to_y; while(.@x != .@to_x || .@y != .@to_y) { sleep2 500; getmapxy .@m$,.@x,.@y,UNITTYPE_PC; } } } return; } function script F_botex { set .@i,0; while (.@i < 1) { set .@b,0; dispbottom .@i+""; .@rid = getcharid(3); getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; .@x = rand(-13,13)+.@x0; .@y = rand(-13,13)+.@y0; sleep2 100; if(!checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate not exists!"; continue; } else if(checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate exists!"; } sleep2 100; while(.@x0 != .@x && .@y0 != .@y) { set .@b,.@b+1; viewpoint 1,.@x,.@y,1,0xFF0000; dispbottom "auto walking to x = "+.@x+" y = "+.@y; unitwalk getcharid(3),.@x,.@y,strnpcinfo(3)+"::OnReach"; sleep2 2000; if(.@b > 5) break; getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; } .@n = getareaunits(BL_MOB,.@m$,.@x0 + 5,.@y0 + 5,.@x0 - 5,.@y0 - 5,.@mob); unitattack 0,.@mob[rand(.@n)],true; percentheal 100,100; sleep2 100; dispbottom "JackJack"; } end; } 1 Quote Link to comment Share on other sites More sharing options...
0 LearningRO Posted December 22, 2018 Group: Members Topic Count: 107 Topics Per Day: 0.02 Content Count: 778 Reputation: 73 Joined: 02/10/12 Last Seen: Yesterday at 12:42 AM Author Share Posted December 22, 2018 On 12/21/2018 at 12:11 AM, n0tttt said: function script random_walk { @walking = !@walking; if(@walking) { while(@walking) { getmapxy .@m$,.@x,.@y,UNITTYPE_PC; getfreecell .@m$,.@to_x,.@to_y,.@x,.@y,10,10; unitwalk getcharid(3),.@to_x,.@to_y; while(.@x != .@to_x || .@y != .@to_y) { sleep2 500; getmapxy .@m$,.@x,.@y,UNITTYPE_PC; } } } return; } function script F_botex { set .@i,0; while (.@i < 1) { set .@b,0; dispbottom .@i+""; .@rid = getcharid(3); getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; .@x = rand(-13,13)+.@x0; .@y = rand(-13,13)+.@y0; sleep2 100; if(!checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate not exists!"; continue; } else if(checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate exists!"; } sleep2 100; while(.@x0 != .@x && .@y0 != .@y) { set .@b,.@b+1; viewpoint 1,.@x,.@y,1,0xFF0000; dispbottom "auto walking to x = "+.@x+" y = "+.@y; unitwalk getcharid(3),.@x,.@y,strnpcinfo(3)+"::OnReach"; sleep2 2000; if(.@b > 5) break; getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; } .@n = getareaunits(BL_MOB,.@m$,.@x0 + 5,.@y0 + 5,.@x0 - 5,.@y0 - 5,.@mob); unitattack 0,.@mob[rand(.@n)],true; percentheal 100,100; sleep2 100; dispbottom "JackJack"; } end; } thx @n0tttt for random walk its work but for auto attack not workin character didn;t hit any monster just random walk Quote Link to comment Share on other sites More sharing options...
0 n0tttt Posted December 22, 2018 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 303 Reputation: 118 Joined: 12/10/16 Last Seen: Friday at 02:39 AM Share Posted December 22, 2018 Maybe now? I read something about rids in unitattack. function script F_botex { set .@i,0; set .@rid,getcharid(3); while (.@i < 1) { set .@b,0; dispbottom .@i+""; .@rid = getcharid(3); getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; .@x = rand(-13,13)+.@x0; .@y = rand(-13,13)+.@y0; sleep2 100; if(!checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate not exists!"; continue; } else if(checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate exists!"; } sleep2 100; while(.@x0 != .@x && .@y0 != .@y) { set .@b,.@b+1; viewpoint 1,.@x,.@y,1,0xFF0000; dispbottom "auto walking to x = "+.@x+" y = "+.@y; unitwalk getcharid(3),.@x,.@y,strnpcinfo(3)+"::OnReach"; sleep2 2000; if(.@b > 5) break; getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; } .@n = getareaunits(BL_MOB,.@m$,.@x0 + 5,.@y0 + 5,.@x0 - 5,.@y0 - 5,.@mob); detachrid; unitattack .@rid,.@mob[rand(.@n)],true; attachrid .@rid; percentheal 100,100; sleep2 100; dispbottom "JackJack"; } end; } 1 Quote Link to comment Share on other sites More sharing options...
0 LearningRO Posted December 28, 2018 Group: Members Topic Count: 107 Topics Per Day: 0.02 Content Count: 778 Reputation: 73 Joined: 02/10/12 Last Seen: Yesterday at 12:42 AM Author Share Posted December 28, 2018 On 12/23/2018 at 5:16 AM, n0tttt said: Maybe now? I read something about rids in unitattack. function script F_botex { set .@i,0; set .@rid,getcharid(3); while (.@i < 1) { set .@b,0; dispbottom .@i+""; .@rid = getcharid(3); getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; .@x = rand(-13,13)+.@x0; .@y = rand(-13,13)+.@y0; sleep2 100; if(!checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate not exists!"; continue; } else if(checkcell( .@m$,.@x,.@y,cell_chkpass )){ dispbottom "Coordinate exists!"; } sleep2 100; while(.@x0 != .@x && .@y0 != .@y) { set .@b,.@b+1; viewpoint 1,.@x,.@y,1,0xFF0000; dispbottom "auto walking to x = "+.@x+" y = "+.@y; unitwalk getcharid(3),.@x,.@y,strnpcinfo(3)+"::OnReach"; sleep2 2000; if(.@b > 5) break; getmapxy(.@m$,.@x0,.@y0,0); sleep2 100; } .@n = getareaunits(BL_MOB,.@m$,.@x0 + 5,.@y0 + 5,.@x0 - 5,.@y0 - 5,.@mob); detachrid; unitattack .@rid,.@mob[rand(.@n)],true; attachrid .@rid; percentheal 100,100; sleep2 100; dispbottom "JackJack"; } end; } still didn't attack any monster near the character Quote Link to comment Share on other sites More sharing options...
Question
LearningRO
hi, all how to make new function when call the function character auto random walk ?
and this function will be used on usable item?
Link to comment
Share on other sites
7 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.