Jump to content
  • 0

NPC that pushes away the player


Erebos

Question


  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  65
  • Reputation:   4
  • Joined:  10/25/18
  • Last Seen:  

I'm trying to do a npc that pushes away the player, whatever the direction the player comes from. I know it can work if i put the specific coordinates but i want to replicate it so i need something that will work in any map. I tried this for start.
 

prontera,50,50,0	script	push	99,3,3,{
OnTouch:
getmapxy(@mapname$, @mapx, @mapy, BL_PC);
getmapxy(@mapnamee$, @x, @y, BL_NPC);

if (@mapx = @x - 3 & @mapy = @y | @mapy = @y + 1 | @mapy = @y +2 | @mapy = @y - 1 | @mapy = @y -2 ) { pushpc DIR_WEST, 2; end; }
if (@mapx = @x - 2 & @mapy = @y - 3 | @mapx = @x - 1 & @mapy = @y - 3 | @mapx = @x & @mapy = @y - 3 | @mapx = @x + 1 & @mapy = @y - 3 | @mapx = @x + 2 & @mapy = @y - 3) { pushpc DIR_SOUTH, 2; end; }

}

This is supposed to push west if the player approach the npc from the left and push south if the player approach from below.
But only the West push works and the South push is pushing West.

Please correct me what im doing wrong, thanks.

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

guild_vs2,50,50,5	script	#asdf	HIDDEN_WARP_NPC,3,3,{
	end;
OnTouch:
	getmapxy .@map$, .@x, .@y, UNITTYPE_PC;
	dispbottom .@x +" "+ .@y;
	if ( .@x == 47 )
		pushpc DIR_WEST, 1;
	else if ( .@x == 53 )
		pushpc DIR_EAST, 1;
	else if ( .@y == 47 )
		pushpc DIR_SOUTH, 1;
	else if ( .@y == 53 )
		pushpc DIR_NORTH, 1;
	end;
}

hercules code, you know how to convert

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  26
  • Topics Per Day:  0.01
  • Content Count:  65
  • Reputation:   4
  • Joined:  10/25/18
  • Last Seen:  

1 hour ago, AnnieRuru said:

guild_vs2,50,50,5	script	#asdf	HIDDEN_WARP_NPC,3,3,{
	end;
OnTouch:
	getmapxy .@map$, .@x, .@y, UNITTYPE_PC;
	dispbottom .@x +" "+ .@y;
	if ( .@x == 47 )
		pushpc DIR_WEST, 1;
	else if ( .@x == 53 )
		pushpc DIR_EAST, 1;
	else if ( .@y == 47 )
		pushpc DIR_SOUTH, 1;
	else if ( .@y == 53 )
		pushpc DIR_NORTH, 1;
	end;
}

hercules code, you know how to convert

So clean! with some modifications i made it work at any coordinates, thanks!

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...