Jump to content
  • 0

using getmapxy to monster


Question

Posted

help me with this script:

this script allow an npc to announce where is $@hehe_gid location coordinates but it doesnt work when announce it says that 0,0 help me with this please

prontera,152,150,5 script eqweq 912,{

set $@hehe_gid,bg_monster(0,"prontera",152,152,"Monster?",1004,"eqweq::OnDied");

getmapxy .@map$, .@x1, .@y1, 3,$@hehe_gid;

announce ""+.@x1+","+.@y1+"",0;

end;

OnDied:

getmapxy .@map$, .@x1, .@y1, 3,$@hehe_gid;

announce ""+.@x1+","+.@y1+"",0;

end;

14 answers to this question

Recommended Posts

Posted

*getmapxy("<variable for map name>",<variable for x>,<variable for y>,<type>{,"<search string>"})
 0 - Character object
 1 - NPC object
 2 - Pet object
 3 - Monster object.
While 3 is meant to look for a monster object, no searching will be done if you
specify type 3, and the function will always return -1.

Afaik, "search string" won't work with monsters. What exactly are you trying to do?

Posted

Since monster summon commands include x,y coordinates, you could set those using a variable beforehand and call that variable in the announce.

Posted (edited)

Using variables in the spawn:

set .@mapname$,"prontera";
set .@x,150;
set .@y,150;
monster .@mapname$,.@x,.@y,"Poring",1002,1,"eqwep::OnMonsterKilled;
announce "I have spawned a Poring on the map "+.@mapname$+" at the coordinates "+.@x+" "+.@y,0;
end;

OnMonsterKilled:
getmapxy(.@mapname2$,.@x2,.@y2,3,"Poring");
announce "The monster has been killed at the coordinates "+.@x2+" "+.@y2+" on the map "+.@mapname2$,0;
end;

You could also use input commands to set the coordinates and map of the spawn.

Like this:

input .@mapname$;
next;
input .@x;
next;
input .@y;
mes "Are you sure you want it spawned here?: "+.@mapname$+" "+.@x+" "+.@y;
menu "Yes",L_spawn,"No",L_cancel;

L_spawn:
monster .@mapname$,.@x,.@y,"Poring",1002,1,"eqwep::OnMonsterKilled";
announce "I have spawned a Poring on the map "+.@mapname$+" at the coordinates "+.@x+" "+.@y,0;
end;
L_cancel:
mes "Very well.";
close;

OnMonsterKilled:
getmapxy(.@mapname2$,.@x2,.@y2,3,"Poring");
announce "The monster has been killed at the coordinates "+.@x2+" "+.@y2+" on the map "+.@mapname2$,0;
end;

Note: I haven't tested the getmapxy like that, but I'm fairly sure that's how it's used.

Also, I'm not sure if it will work because of the monster being dead when it's executed. My guess is that it won't though.

Edited by Joey
Posted

As I thought, using getmapxy on a monster after it's dead won't work. You'll have to use the coordinates of the spawn in the broadcast instead.

Preset in script variables:

set .@mapname$,"prontera";
set .@x,150;
set .@y,150;
monster .@mapname$,.@x,.@y,"Poring",1002,1,"eqwep::OnMonsterKilled;
announce "I have spawned a Poring on the map "+.@mapname$+" at the coordinates "+.@x+" "+.@y,0;
end;

OnMonsterKilled:
announce "The monster has been killed at the coordinates "+.@x+" "+.@y+" on the map "+.@mapname$,0;
end;

Spawn input:

input .@mapname$;
next;
input .@x;
next;
input .@y;
mes "Are you sure you want it spawned here?: "+.@mapname$+" "+.@x+" "+.@y;
menu "Yes",L_spawn,"No",L_cancel;

L_spawn:
monster .@mapname$,.@x,.@y,"Poring",1002,1,"eqwep::OnMonsterKilled";
announce "I have spawned a Poring on the map "+.@mapname$+" at the coordinates "+.@x+" "+.@y,0;
end;
L_cancel:
mes "Very well.";
close;

OnMonsterKilled:
announce "The monster has been killed at the coordinates "+.@x+" "+.@y+" on the map "+.@mapname$,0;
end;

Posted (edited)

so the getmapxy doesn't work on mobs? I'm actually making a monster with died it will drop a custom item by chance of the xy coordinates where the monster died /sob I'm failed

but thank you so much sir joey and sir euphy

Edited by hakuren
Posted (edited)

you can try modify src let it return dead x ,y coordinate

mob.c

find

#include "quest.h"

add after

#include "mapreg.h"

find

  if( md->npc_event[0] && !md->state.npc_killmonster )

add after

mapreg_setreg(add_str("$@mobdead_x"), md->bl.x);
mapreg_setreg(add_str("$@mobdead_y"), md->bl.y);

recompile...

It should return last mob dead coordinate x ($@mobdead_x) and y($@mobdead_y)

Edited by QQfoolsorellina
  • Love 1
Posted

Since I don't know anything about SRC, what would it be to add the mapname as well?

for return mapname just add this line

mapreg_setregstr(add_str("$@mobdead_m$"+0), map[md->bl.m].name);

variable $@mobdead_m$ will save last mob dead map

@hakuren

U R welcome , glad to help :)

  • Love 1

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