Jump to content
  • 0

get mob x and y position


Dissidia

Question


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  535
  • Reputation:   23
  • Joined:  11/19/11
  • Last Seen:  

after you kill the monster get the x and y coordinate of the monster you killed.

this is possible?

Link to comment
Share on other sites

10 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.00
  • Content Count:  764
  • Reputation:   220
  • Joined:  11/14/11
  • Last Seen:  

In ../src/map/mob.c find this function:

int mob_dead(struct mob_data *md, struct block_list *src, int type)

X:

md->bl.x

Y;

md->bl.y

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  535
  • Reputation:   23
  • Joined:  11/19/11
  • Last Seen:  

sir in script how to add?

example:

set @mobcoordinatex,getmobx;

set @mobcoordinatey,getmoby;

Edited by Lionheart
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  106
  • Reputation:   28
  • Joined:  11/08/11
  • Last Seen:  

I'm not at home so I couldn't test if it's actually working.

The following changes set the variables killed_x and killed_y when a monster (and player if you like) is killed. It works exactly like killedid, just with the coordinates instead of the id.

Find (src/map/map.h:308):

SP_KILLEDRID=122,

Add after:

SP_KILLED_X=123,
SP_KILLED_Y=124,

Find (src/map/pc.c:6035):

case SP_KILLEDRID:   val = sd->killedrid; break;

Add after:

case SP_KILLED_X:   val = sd->killed_x; break;
case SP_KILLED_Y:   val = sd->killed_y; break;

Find (src/map/pc.c:6177):

	case SP_KILLEDRID:
	sd->killedrid = val;
	return 1;

Add after:

	case SP_KILLED_X:
	sd->killed_x = val;
	return 1;
case SP_KILLED_Y:
	sd->killed_y = val;
	return 1;

Find (src/map/mob.c:2429):

	pc_setparam(mvp_sd, SP_KILLEDRID, md->class_);

Add after:

	pc_setparam(mvp_sd, SP_KILLED_X, md->bl.x);
pc_setparam(mvp_sd, SP_KILLED_Y, md->bl.y);

Find (src/map/pc.h:390):

	int killerrid, killedrid;

Add after:

	int killed_x, killed_y;

Find (db/const.txt:296):

killedrid	122	1

Add after:

killed_x	123	1
killed_y	124	1

(Edit:) Sets the variables for custom mob kill events and killed players as well.

Find (src/map/mob.c:2416):

				pc_setparam(sd, SP_KILLERRID, sd->bl.id);

Add after:

				pc_setparam(sd, SP_KILLED_X, sd->bl.x);
			pc_setparam(sd, SP_KILLED_Y, sd->bl.y);

Find (src/map/mob.c:2421):

				pc_setparam(mvp_sd, SP_KILLERRID, sd?sd->bl.id:0);

Add after:

				pc_setparam(mvp_sd, SP_KILLED_X, sd?sd->bl.x:0);
			pc_setparam(mvp_sd, SP_KILLED_Y, sd?sd->bl.y:0);

Find (src/map/pc.c:5719):

	pc_setparam(sd, SP_KILLERRID, src?src->id:0);

Add After:

	pc_setparam(sd, SP_KILLED_X, src?src->x:0);
pc_setparam(sd, SP_KILLED_Y, src?src->y:0);

(/Edit)

If you want to add the x and y coordinates for player kills as well:

Find (src/map/pc.c:5778):

		pc_setparam(ssd, SP_KILLEDRID, sd->bl.id);

Add after:

		pc_setparam(ssd, SP_KILLED_X, sd->bl.x);
	pc_setparam(ssd, SP_KILLED_Y, sd->bl.y);

Edited by Toshiro
  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  186
  • Reputation:   51
  • Joined:  11/14/11
  • Last Seen:  

This isnt possible without the old unit control commands or a new modification.

I've made a simple one, allowing to do:

OnNPCKillEvent:
dispBottom("You killed monster " + getMonsterInfo(killedRID, 0) + " @ " + killedRX + "/" + killedRY);
end;

€dit: Even if @Toshiro was faster - mine also works for player kills :o

killedrx_killedry.diff

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  2
  • Topics Per Day:  0.00
  • Content Count:  106
  • Reputation:   28
  • Joined:  11/08/11
  • Last Seen:  

This isnt possible without the old unit control commands or a new modification.

I've made a simple one, allowing to do:

OnNPCKillEvent:
dispBottom("You killed monster " + getMonsterInfo(killedRID, 0) + " @ " + killedRX + "/" + killedRY);
end;

€dit: Even if @Toshiro was faster - mine also works for player kills :o

You actually didn't add that the variables are set for the killing player, just for the player that was killed. But you added it for custom mob kill event which I previously forgot.

Updated my first post with additions for variables for the killed player and custom mob kill events.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  186
  • Reputation:   51
  • Joined:  11/14/11
  • Last Seen:  

You actually didn't add that the variables are set for the killing player, just for the player that was killed.

Because if you are the killing player, your position can easily be fetched using getmapxy ^^ Only the target position, the killed player, needs to be attached, checked if still online & then getmapxy, bla.

Anyways, we should stay @ one modification to not confuse the poeple :S

I dont care if we use mine or yours.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

This would be useful for the Mob Tombstone system!

(Does anyone know how it is on official servers: does the tombstone appear at the x,y where the MVP died? or at the x,y where the player was standing?)

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  155
  • Topics Per Day:  0.03
  • Content Count:  535
  • Reputation:   23
  • Joined:  11/19/11
  • Last Seen:  

thank you sirs.. this is very usefull in tombstone system

Edited by Lionheart
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  198
  • Reputation:   102
  • Joined:  11/13/11
  • Last Seen:  

I think you want something like this:

http://trac.brathena.org/changeset/929

http://trac.brathena.org/changeset/931

You can study and modify the code, i ask only that you keep the credits.

Edited by Protimus
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  33
  • Reputation:   0
  • Joined:  12/17/11
  • Last Seen:  

Is there any need of a Tombstone Script to Link with this Mod?..

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