Jump to content
  • 0

Help Me in Unitwalk


Question

Posted

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_datasd)
{
    if(mapindex_id2name(sd->bl.m== "new_1-1"){
        unit_walktoxy(&sd->bl1351130);
    }
    return;
}

 

7 answers to this question

Recommended Posts

  • 0
Posted
		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.

  • 0
Posted

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

  • 0
Posted
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
                }

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...