Jump to content
  • 0

Help Me in Unitwalk


nasagnilac

Question


  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

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;
}

 

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.01
  • Content Count:  416
  • Reputation:   73
  • Joined:  05/16/19
  • Last Seen:  

why cant you just use an npc script for that? 

 

not sure try recompiling

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   260
  • Joined:  04/25/12
  • Last Seen:  

Breakpoints are your friend

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

		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.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  20
  • Topics Per Day:  0.01
  • Content Count:  416
  • Reputation:   73
  • Joined:  05/16/19
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.02
  • Content Count:  176
  • Reputation:   60
  • Joined:  01/11/19
  • Last Seen:  

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?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

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
                }
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  89
  • Topics Per Day:  0.02
  • Content Count:  232
  • Reputation:   15
  • Joined:  11/02/13
  • Last Seen:  

Look like the wall cause the issue.

Link to comment
Share on other sites

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.

×
×
  • Create New...