Jump to content

How to make npc to move to a specified location


Recommended Posts

Hello,

i have a nice and orginial idea,but i don't know how can i do it.

I'm sure there is a function or something that can make a NPC to move to a specified location when a quest is activated.

Example:
Let's say you go to General Story and there is a quest. She ask you to wait till she go to her father (Armor vendor) to get something.When the quest is acceptet she move to the Armor vendor for 1 minute,then she came back and give you a reword for keeping her store till she was away.

 

I'm sure this is possible,because you can set a npc to move from database,but it goes to random locations.

 

 

Can you help me guys with some advice? 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Bronze

There's no quest function for that, you'd have to make your own, something like this:

// Syntax: npc.move(map_index, local x, local y)
int npc_move(lua_State* L)
{
    if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3))
    {
        lua_pushboolean(L, FALSE);
        return 1;
    }

    LPCHARACTER pkNPC = CQuestManager::instance().GetCurrentNPCCharacterPtr();
    if (!pkNPC)
    {
        lua_pushboolean(L, FALSE);
        return 1;
    }

    long lMapIndex = lua_tonumber(L, 1);
    long lX = lua_tonumber(L, 2);
    long lY = lua_tonumber(L, 3);

    LPSECTREE_MAP pkSectreeMap = SECTREE_MANAGER::instance().GetMap(lMapIndex);
    if (!pkSectreeMap)
        return 0;

    if (pkNPC->Goto(pkSectreeMap->m_setting.iBaseX + lX, pkSectreeMap->m_setting.iBaseY + lY))
    {
        pkNPC->SendMovePacket(FUNC_WAIT, 0, 0, 0, 0);
        lua_pushboolean(L, TRUE);
    }
    else
    {
        lua_pushboolean(L, FALSE);
    }

    return 1;
}

IT'S UNTESTED!

 

Regards

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.