Jump to content

jump party to different position


Go to solution Solved by VegaS™,

Recommended Posts

Hi 

Let us get into it straight away 

 

well i did this function 

void CParty::JumpParty(LPPARTY pParty, int x, int y)
{

	FWarpToPosition f(x, y);

	pParty->ForEachNearMember(f);
}

in party.cpp 

it is for warp all party members

 

the thing is that after warp all players will be in same position ,

i want that after warp each party member have some distance between each other ( not all in same position )

 

some dev gave me this but it didn't work 

void CParty::JumpParty(LPPARTY pParty, int x, int y)
{
	/// POSITION_MARKING
	int iPixelPos[PARTY_MAX_MEMBER][2] =
	{
		{50, 50},
		{50, 0},
		{50, -50},
		{50, 50},
		{50, 0},
		{50, -50},
		{50, 0},
		{50, -50},
	};
	/// END_OF_POSITION_MARKING

	int n = 0;
	while (n < GetNearMemberCount())
	{
		FWarpToPosition f(x + iPixelPos[n][0], y + iPixelPos[n][1]);
		pParty->ForEachNearMember(f);
		++n;
	}
}

 

 

any clue ? 

 

 

 

Link to comment
Share on other sites

Why while statement lol

 

struct FWarpToPosition
{
	long lMapIndex;
	long x;
	long y;
	FWarpToPosition(long lMapIndex, long x, long y)
		: lMapIndex(lMapIndex), x(x), y(y)
		{}

	void operator()(LPENTITY ent)
	{
		if (!ent->IsType(ENTITY_CHARACTER)) {
			return;
		}
		LPCHARACTER ch = (LPCHARACTER)ent;
		if (!ch->IsPC()) {
			return;
		}
		if (ch->GetMapIndex() == lMapIndex)
		{
			ch->Show(lMapIndex, x, y, 0);
			ch->Stop();
		}
		else
		{
			BYTE RandomNumber = number(0, 15);
			ch->WarpSet(x + RandomNumber, y + RandomNumber, lMapIndex);
		}
	}
};

 

  • Love 1
Link to comment
Share on other sites

9 minutes ago, ManiacRobert said:

Why while statement lol

 


struct FWarpToPosition
{
	long lMapIndex;
	long x;
	long y;
	FWarpToPosition(long lMapIndex, long x, long y)
		: lMapIndex(lMapIndex), x(x), y(y)
		{}

	void operator()(LPENTITY ent)
	{
		if (!ent->IsType(ENTITY_CHARACTER)) {
			return;
		}
		LPCHARACTER ch = (LPCHARACTER)ent;
		if (!ch->IsPC()) {
			return;
		}
		if (ch->GetMapIndex() == lMapIndex)
		{
			ch->Show(lMapIndex, x, y, 0);
			ch->Stop();
		}
		else
		{
			BYTE RandomNumber = number(0, 15);
			ch->WarpSet(x + RandomNumber, y + RandomNumber, lMapIndex);
		}
	}
};

 

thank you but this will only warp one player 

 

what i want is to warp all party members ..

using this function .. 

pParty->ForEachNearMember(f);

 

 

Link to comment
Share on other sites

  • Premium

And why exactly do you need source functions for that?

 

For dungeons:

local difference = math.random(1, 3);
d.jump_all(localPositionX + difference, localPositionY + difference);

--Or, if you need it for the dungeon creation:
local difference = math.random(1, 3);
d.new_jump_party(dungeon_index, positionX + difference, positionY + difference);

Or, if you're not inside a dungeon instance:

local difference = math.random(1, 3);
local pids = {party.get_member_pids()};

for _, pid in ipairs(pids) do
	q.begin_other_pc_block(pid);
	pc.warp(positionX + difference, positionY + difference);
	q.end_other_pc_block();
end -- for

-- Or, if the position is local (same map)
local difference = math.random(1, 3);
local pids = {party.get_member_pids()};

for _, pid in ipairs(pids) do
	q.begin_other_pc_block(pid);
	pc.warp_local(localPositionX + difference, localPositionY + difference);
	q.end_other_pc_block();
end -- for

 

  • Love 3

 

"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

  • Forum Moderator
On 12/2/2019 at 3:33 PM, ManiacRobert said:

Why while statement lol

The while is with a scope, he wanted to make for each player an specific position, not random position.

@jeddawee You could atleast to post the FWarpToPosition from party.cpp, i see that you use the struct without the first argument as lMapIndex like dungeon.cpp, if you use another struct and not the one from dungeon.cpp, just send me a pm and let's don't make a spam topic.

This is the hidden content, please

 

Edited by VegaS™
  • Metin2 Dev 3
  • Love 1
Link to comment
Share on other sites

  • Premium

If he wanted the players in the party to have specific difference in coordinates then it's also simple to do it, like this.

local pids = {party.get_member_pids()};
local difference = {
	[1] = {["x"] = 0,   ["y"] = -50},
 	[2] = {["x"] = 50,  ["y"] = -50},
 	[3] = {["x"] = -50, ["y"] = -50},
  	[4] = {["x"] = 0,   ["y"] = 50},
	[5] = {["x"] = 50,  ["y"] = 50},
	[6] = {["x"] = -50, ["y"] = 50},
	[7] = {["x"] = 0,   ["y"] = 0},
	[8] = {["x"] = 50,  ["y"] = 0}
};

for index, pid in ipairs(pids) do
	q.begin_other_pc_block(pid);
	pc.warp(positionX + difference[index]["x"], positionY + difference[index]["y"]);
	q.end_other_pc_block();
end -- for

-- Or, if the position is local (same map)
for index, pid in ipairs(pids) do
	q.begin_other_pc_block(pid);
	pc.warp_local(localPositionX + difference[index]["x"], localPositionY + difference[index]["y"]);
	q.end_other_pc_block();
end -- for

 

  • Love 2

 

"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

3 hours ago, ManiacRobert said:

Just try to replace my function with yours in dungeon.cpp ...

yes your code worked i just had to x100 the number(0, 15 ) xDD

But yeah as @VegaS™ said , i want the party warp in fixed order not random order 

 

 

1 hour ago, Syreldar said:

If he wanted the players in the party to have specific difference in coordinates then it's also simple to do it, like this.


local pids = {party.get_member_pids()};
local difference = {
	[1] = {0, -50},
 	[2] = {50, -50},
 	[3] = {-50, -50},
  	[4] = {0, 50},
	[5] = {50, 50},
	[6] = {-50, 50},
	[7] = {0, 0},
	[8] = {50, 0}
};

for index, pid in ipairs(pids) do
	q.begin_other_pc_block(pid);
	pc.warp(localPositionX + difference[index][1], localPositionY + difference[index][2]);
	q.end_other_pc_block();
end -- for

-- Or, if the position is local (same map)
local difference = math.random(1, 3);
local pids = {party.get_member_pids()};

for index, pid in ipairs(pids) do
	q.begin_other_pc_block(pid);
	pc.warp_local(positionX + difference[index][1], positionY + difference[index][2]);
	q.end_other_pc_block();
end -- for

 

 thank you for helping ❤️

 

Link to comment
Share on other sites

  • Forum Moderator
  • Solution

As i thought, that's what he needed:

This is the hidden content, please

  • Metin2 Dev 7
  • Good 1
  • Love 3
Link to comment
Share on other sites

4 minutes ago, VegaS™ said:

As i thought, that's what he needed:


void CParty::JumpParty(const long lX, const long lY)
{
	static const int32_t iPixelPos[PARTY_MAX_MEMBER][2] =
	{
		{50, 50},
		{50, 0},
		{50, -50},
		{50, 50},
		{50, 0},
		{50, -50},
		{50, 0},
		{50, -50},
	};

	if (_countof(iPixelPos) < m_memberMap.size())
		return;
	
	uint8_t iPos = 0;
	for (TMemberMap::const_iterator it = m_memberMap.begin(); it != m_memberMap.end(); ++it)
	{
		const LPCHARACTER ch = it->second.pCharacter;
		if (ch && it->second.bNear)
		{
			const int32_t iDiffX = iPixelPos[iPos][0];
			const int32_t iDiffY = iPixelPos[iPos][1];

			ch->WarpSet(lX + iDiffX, lY + iDiffY);
			++iPos;
		}
	}
}

 

fixed, 

thank you man so much ❤️

i know my explanation was bad but you could get what i need exactly xD

 

 

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.