Jump to content
  • 0

GetDirection()...


Question

Posted (edited)

I'l like to request a getdirection npc command.... for example...
 

prontera,101,101,2	script	DirectionGet	100,{
//Variables
	set .rid, getcharid(3);
	set .gid, bg_monster(.@group,"prontera",101,101,"Poringz0rd",1002,"");
	set .npc$, "OtherNPC";

	mes ""+	getdirection(.gid); //Would return the monsters direction. 0-7
	mes ""+	getdirection(.rid); //Would return the players direction. 0-7
	mes ""+	getdirection(); //Would return 2 the npcs direction...
	mes ""+	getdirection(.npc$); //Would return the other npcs direction.
	end;
}


It would return the value of direction.

I think this can be done easily from source with...

unit_getdir()

.. But i'm not sure how to make new npc commands...

tytyty!!

Edited by Skorm

4 answers to this question

Recommended Posts

Posted

try this ...

BUILDIN_FUNC(getdirection)
{
    int udir;
    struct block_list* bl;

    bl = map_id2bl(script_getnum(st,2));

    if( bl == NULL ){
        script_pushint(st,-1);
        return 0;
    }    

    udir = (bl->type == BL_NPC ? ((TBL_NPC*)bl)->ud.dir :unit_bl2ud(bl)->dir);

    script_pushint(st,udir);

    return 0;
}


BUILDIN_DEF(getdirection,"i"),
  • Upvote 1
Posted (edited)
BUILDIN_FUNC(getdirection)
{
    int udir;
    struct block_list* bl;
    struct unit_data *ud = NULL;

     bl = map_id2bl(script_getnum(st,2));

    if( bl == NULL ){
        script_pushint(st,-1);
        return 0;
    }

    ud = unit_bl2ud(bl);

    if(ud == NULL){
        script_pushint(st,-1);
        return 0;
    }

    udir = ud->dir;

    script_pushint(st,udir);

    return 0;
}

BUILDIN_DEF(getdirection,"i"),

if GID not  exist  return -1

not tested ,try it

Edited by QQfoolsorellina
Posted (edited)
BUILDIN_FUNC(getdirection)
{
    int udir;
    struct block_list* bl;
    struct unit_data *ud = NULL;

     bl = map_id2bl(script_getnum(st,2));

    if( bl == NULL ){
        script_pushint(st,-1);
        return 0;
    }

    ud = unit_bl2ud(bl);

    if(ud == NULL){
        script_pushint(st,-1);
        return 0;
    }

    udir = ud->dir;

    script_pushint(st,udir);

    return 0;
}

BUILDIN_DEF(getdirection,"i"),

if GID not  exist  return -1

not tested ,try it

 

Is there anyway I can return the NPCs direction as well? Right now only gid and rid seem to work.

 

Edit: I tried sending the npcs GID through as a parameter and that didn't seem to work either.

Edited by Skorm
Posted (edited)

try this ...

 

BUILDIN_FUNC(getdirection)
{
    int udir;
    struct block_list* bl;

    bl = map_id2bl(script_getnum(st,2));

    if( bl == NULL ){
        script_pushint(st,-1);
        return 0;
    }    

    udir = (bl->type == BL_NPC ? ((TBL_NPC*)bl)->ud.dir :unit_bl2ud(bl)->dir);

    script_pushint(st,udir);

    return 0;
}


BUILDIN_DEF(getdirection,"i"),

 

I'll be sure to try this when I get home... or after I wake up... haven't slept in over 24 hours.

 


 

try this ...

 

BUILDIN_FUNC(getdirection)
{
    int udir;
    struct block_list* bl;

    bl = map_id2bl(script_getnum(st,2));

    if( bl == NULL ){
        script_pushint(st,-1);
        return 0;
    }    

    udir = (bl->type == BL_NPC ? ((TBL_NPC*)bl)->ud.dir :unit_bl2ud(bl)->dir);

    script_pushint(st,udir);

    return 0;
}


BUILDIN_DEF(getdirection,"i"),

 

Working perfectly tytyty, pretty lady!

 

Personally I think this should be added to the SVN because seriously why the hell don't they have this yet.

Edited by Skorm

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