nasagnilac Posted September 27, 2019 Posted September 27, 2019 I have this code that should walk the character when he/she is in the same map. When I tried it nothing happens. Any tips for this? Quote void auto_newbie_move(struct map_session_data* sd) { if(mapindex_id2name(sd->bl.m) == "new_1-1"){ unit_walktoxy(&sd->bl, 135, 113, 0); } return; } Quote
0 Naruto Posted September 27, 2019 Posted September 27, 2019 why cant you just use an npc script for that? not sure try recompiling Quote
0 nasagnilac Posted September 27, 2019 Author Posted September 27, 2019 if(!target_id && battle_config.player_dummy_move){ if (map_getmapdata(sd->bl.m)->name == "new_1-1" && !pc_isdead(sd)) { unit_walktoxy(&sd->bl, 135, 113, 0); }else{ unit_walktoxy(&sd->bl, sd->bl.x + (rand() % 2 == 0 ? -1 : 1)*(rand() % battle_config.player_dummy_move_cell), sd->bl.y + (rand() % 2 == 0 ? -1 : 1)*(rand() % battle_config.player_dummy_move_cell), 0); } } I am working on auto attack but don't know the right code to compare it with map name like new_1-1. Quote
0 Naruto Posted September 27, 2019 Posted September 27, 2019 well I remember having issues trying to automatically move characters using that script when trying to move outside the what... 12 cell range? With mobs you have to keep refreshing it, and stuff, super annoying gl Quote
0 Seravy Posted September 27, 2019 Posted September 27, 2019 As far as I remember, in C languages you can't use == for strings because it compares the pointers instead of the contents. You have to use something else, strcmp maybe? Quote
0 nasagnilac Posted September 28, 2019 Author Posted September 28, 2019 11 hours ago, Seravy said: As far as I remember, in C languages you can't use == for strings because it compares the pointers instead of the contents. You have to use something else, strcmp maybe? I tried it but still working and I adjust the code to this base on unitwalk scriptcommand. If you are going to use unitwalk its working. if (strcmp("new_1-1", map_getmapdata(sd->bl.m)->name)) { int x = 135; int y = 113; add_timer(gettick()+50, unit_delay_walktoxy_timer, sd->bl.id, (x<<16)|(y&0xFFFF)); // Need timer to avoid mismatches } Quote
0 nasagnilac Posted September 28, 2019 Author Posted September 28, 2019 Look like the wall cause the issue. Quote
Question
nasagnilac
I have this code that should walk the character when he/she is in the same map.
When I tried it nothing happens. Any tips for this?
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.