Jump to content
×
×
  • Create New...
  • 0

How to make npc to move to a specified location


acorex

Question

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

  • Answers 2
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

2 answers to this question

Recommended Posts

  • 0

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


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.