Jump to content

[Request] d.warp_local() function for LUA


Go to solution Solved by Aveline™,

Recommended Posts

Hi com, 

I'm here to ask for a new function that is working like pc.warp_local() but in a dungeon, and to a single player not to the whole group.

The effect should be like a /go. If I use pc.warp_local() it kicks the player out of the dungeon...

 

 

If there is any other way how to fix this without a new function you can also tell me how to. :)
I tried : pc.warp_local(d.get_ma_index(), X, Y ) but it gave me the error : "53003 no valid mapindex"

 

 

I hope someone can help me :)

MFG Castro

Link to comment
Share on other sites

  • Premium

Hi com, 

I'm here to ask for a new function that is working like pc.warp_local() but in a dungeon, and to a single player not to the whole group.

The effect should be like a /go. If I use pc.warp_local() it kicks the player out of the dungeon...

 

 

If there is any other way how to fix this without a new function you can also tell me how to. :)

I tried : pc.warp_local(d.get_ma_index(), X, Y ) but it gave me the error : "53003 no valid mapindex"

 

 

I hope someone can help me :)

MFG Castro

Excuse me, but i don't understand you, the function you're talking about is "pc.warp_local()" or "d.warp_local()"?

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Solution

how it's not works? 

 

Can you explain or is there anything about this?

 

If you want to new function like pc.warp_local, here ;)

	int dungeon_warp_local(lua_State* L)
	{
		if (!lua_isnumber(L, 1)) 
		{
			sys_err("no map index argument");
			return 0;
		}

		if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3))
		{
			sys_err("no coodinate argument");
			return 0;
		}

		long lMapIndex = (long) lua_tonumber(L, 1);
		const TMapRegion * region = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex);

		if (!region)
		{
			sys_err("invalid map index %d", lMapIndex);
			return 0;
		}

		int x = (int) lua_tonumber(L, 2);
		int y = (int) lua_tonumber(L, 3);

		if (x > region->ex - region->sx)
		{
			sys_err("x coordinate overflow max: %d input: %d", region->ex - region->sx, x);
			return 0;
		}

		if (y > region->ey - region->sy)
		{
			sys_err("y coordinate overflow max: %d input: %d", region->ey - region->sy, y);
			return 0;
		}

		CQuestManager::instance().GetCurrentCharacterPtr()->WarpSet(region->sx + x, region->sy + y);
		return 0;
	}

Kind Regards

HaveBeen

  • Love 1

Plain logic saves lives.

Link to comment
Share on other sites

how it's not works? 

 

Can you explain or is there anything about this?

 

If you want to new function like pc.warp_local, here ;)

	int dungeon_warp_local(lua_State* L)
	{
		if (!lua_isnumber(L, 1)) 
		{
			sys_err("no map index argument");
			return 0;
		}

		if (!lua_isnumber(L, 2) || !lua_isnumber(L, 3))
		{
			sys_err("no coodinate argument");
			return 0;
		}

		long lMapIndex = (long) lua_tonumber(L, 1);
		const TMapRegion * region = SECTREE_MANAGER::instance().GetMapRegion(lMapIndex);

		if (!region)
		{
			sys_err("invalid map index %d", lMapIndex);
			return 0;
		}

		int x = (int) lua_tonumber(L, 2);
		int y = (int) lua_tonumber(L, 3);

		if (x > region->ex - region->sx)
		{
			sys_err("x coordinate overflow max: %d input: %d", region->ex - region->sx, x);
			return 0;
		}

		if (y > region->ey - region->sy)
		{
			sys_err("y coordinate overflow max: %d input: %d", region->ey - region->sy, y);
			return 0;
		}

		CQuestManager::instance().GetCurrentCharacterPtr()->WarpSet(region->sx + x, region->sy + y);
		return 0;
	}

Kind Regards

HaveBeen

 Thats excactly what i wanted^^ will test it soon! thanks bro!

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.