Jump to content
  • 0

[Fixed] Two Party in One Instance


Wise

Question


  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

edit: i got it working thanks.

heres my solution and sample working BG for a 2v2

prontera,162,190,4	script	Sample Instance BG	469,{
	// Important Variables
	.@instance$ = "Instance BG"; // Battleground Name
	.@npcname$ = "[^FF0000Queue^000000]"; // NPC Name
	.@requiredmembers = 2; // Required Members

	mes .@npcname$;
	
	// Checks if character's current party ID is in an instance
	if (instance_id()) {
		mes "You are already participating on an instance, please make sure to leave the party before queueing.";
		close;
	}
	
	// Checks if character is in a party
	if (getcharid(1) == 0) {
		mes "You are currently not in a party.";
		close;
	}
	
	// Checks if you are the party leader
	if( !getcharid(1) || getcharid(3) != getpartyleader(getcharid(1),1)){
		.@targetID = getpartyleader(getcharid(1),1);
		mes "Please inform ^FF0000"+rid2name(.@targetID)+"^000000 to queue for the battleground.";
		close;
	}
	
	// Checks if NPCMatch is full AND participating the match
	if ($NPCMatch == 2 && ($PartyA == getcharid(1) || $PartyB == getcharid(1))) {
	mes "Your match is in progress...";
	close;
	}
	
	// Checks if you have less than or more than the amount of members required
	getpartymember getcharid(1),0;
	getpartymember getcharid(1),1;
	getpartymember getcharid(1), 2;
	.@count = $@partymembercount;
	if (.@count > .@requiredmembers) {
	mes "You have exceeded the limit of "+.@requiredmembers+" to queue.";
	close;
	} else if (.@count < .@requiredmembers) {
	mes "You do not have enough members to queue.";
	close;
	}
	
	// If every checks are good, do this
	.@count = $@partymembercount;
	copyarray .@name$[0], $@partymembername$[0], $@partymembercount;
	copyarray .@cid[0], $@partymembercid[0], $@partymembercount;
	// list the party member names
	mes "Here is the list of participating members:";
	mes "^efefff_^000000";
	for (.@i = 0; .@i < .@count; .@i++)
		mes (.@i +1) + ". ^0000FF" + .@name$[.@i] + "^000000 "+.@cid[.@i];
	next;
	switch(select("Queue for Battleground:Information:Reset Variables:Teleport")) {
		case 1:
			mes .@npcname$;
			
			// Party B Instance Creation
			if ($PartyA == 1) {
				.@instance_id = instance_create(.@instance$,1,.@cid[0]);
			
				// Check to see if instance creation failed.
				if (.@instance_id < 0) {
					switch (.@create) {
						case -1: mes "ERROR: Invalid type."; break;
						case -2: mes "ERROR: Party not found."; break;
						case -3: mes "ERROR: Instance already exists."; break;
						case -4: mes "ERROR: No free instances."; break;
					}
					mes " ";
					mes "Instance creation ^FF0000failed^000000.";
					emotion e_omg;
					close;
				}
				
				
				// Proceed to instance_create
				mes "In queue for battleground...";
				$PartyB = 1; // Occupy the Party B spot globally
				$NPCMatch = 2; // Makes $NPCMatch = 1, needs one more to queue.
				$PartyB1 = .@cid[0]; // Makes $PartyB1 the Party Member 1's charID
				$PartyB2 = .@cid[1]; // Makes $PartyB2 the Party Member 2's charID
				$InstanceIDB = instance_id();
				close2;
				announce "[Queue]: You found a match!",bc_self,"0x00ff99"; // Need to find out how to send announce to people in certain character IDs
					addtimer 5000, strnpcinfo(3)+"::On5secs";
					end;
				On5secs: // Teleport the people in queue to the designated map
					warp $MapName$,7,50,$PartyA1;
					warp $MapName$,7,50,$PartyA2;
					warp $MapName$,92,50,$PartyB1;
					warp $MapName$,92,50,$PartyB2;
					//donpcevent instance_npcname("BattlegroundEvent")+"::OnInstanceInit";
					end;
			}
			
			// Party A Instance Creation
			.@instance_id = instance_create(.@instance$,1,.@cid[0]);
			
			// Check to see if instance creation failed.
			if (.@instance_id < 0) {
				switch (.@create) {
					case -1: mes "ERROR: Invalid type."; break;
					case -2: mes "ERROR: Party not found."; break;
					case -3: mes "ERROR: Instance already exists."; break;
					case -4: mes "ERROR: No free instances."; break;
				}
				mes " ";
				mes "Instance creation ^FF0000failed^000000.";
				emotion e_omg;
				close;
			}
		
			// Proceed to instance_create
			mes "In queue for battleground...";
			$PartyA = 1; // Occupy the Party A spot globally
			$NPCMatch = 1; // Makes $NPCMatch = 1, needs one more to queue.
			$PartyA1 = .@cid[0]; // Makes $PartyA1 the Party Member 1's charID
			$PartyA2 = .@cid[1]; // Makes $PartyA2 the Party Member 2's charID
			$InstanceIDA = instance_id();
			$MapName$ = instance_mapname("arena", instance_id());
			close;
		case 2: // Shows the scripter if variables are working as intended
			mes .@npcname$;
			mes "$NPCMatch = "+$NPCMatch;
			mes "$PartyA = "+$PartyA;
			mes "$PartyB = "+$PartyB;
			mes "$PartyA1 = "+$PartyA1;
			mes "$PartyA2 = "+$PartyA2;
			mes "$PartyB1 = "+$PartyB1;
			mes "$PartyB2 = "+$PartyB2;
			mes "$InstanceIDA = "+$InstanceIDA;
			mes "$InstanceIDB = "+$InstanceIDB;
			mes "My instance_id() = "+instance_id();
			mes "$MapName$ = "+$MapName$;
			close;
		case 3: // Resets the global variables
			mes .@npcname$;
			$NPCMatch = 0;
			$PartyA = 0;
			$PartyB = 0;
			$PartyA1 = 0;
			$PartyA2 = 0;
			$PartyB1 = 0;
			$PartyB2 = 0;			
			instance_destroy instance_id();
			$InstanceIDA = 0;
			$InstanceIDB = 0;
			$MapName$ = 0;
			//party_destroy(getcharid(1)); // Disbands the party.
			mes "$NPCMatch = "+$NPCMatch;
			mes "$PartyA = "+$PartyA;
			mes "$PartyB = "+$PartyB;
			mes "$PartyA1 = "+$PartyA1;
			mes "$PartyA2 = "+$PartyA2;
			mes "$PartyB1 = "+$PartyB1;
			mes "$PartyB2 = "+$PartyB2;
			mes "$InstanceIDA = "+$InstanceIDA;
			mes "$InstanceIDB = "+$InstanceIDB;
			mes "My instance_id() = "+instance_id();
			mes "$MapName$ = "+$MapName$;
			close;
		case 4: // Force teleport the players in queue.
			warp $MapName$,7,50,$PartyA1;
			warp $MapName$,7,50,$PartyA2;
			warp $MapName$,92,50,$PartyB1;
			warp $MapName$,92,50,$PartyB2;
		close;
	}
}

 

So I have this idea of making an instanced PVP, or what you call a battleground lol! The problem that I am facing is this new rewritten function of

instance_enter(.@pvpname$,7,50,$Party1_Char1,$InstanceID_A); 

Sample Variable:

.@pvpname$ = "Arena";

$Party1_Char1 = 150001;

$InstanceID_A = 1;

What it does is it teleports 150001 to the instance in coordinate of 7,50. So that one works, but if I switch the second formula into this:

instance_enter(.@pvpname$,92,50,$Party2_Char1,$InstanceID_A); // Given that Party2_Char1 is 150002, and when it made an instance, it's instance_id() becomes 2 *since 1 is already taken by Party1. 

What it should do is to teleport 150002 to Instance ID 1, but it's not letting it teleport to that certain instance. How can I make this happen? :)

 

Edit:

Attempt #2:

So maybe I thought I could read more about instance_create, and found out that this is the function: instance_create("<instance name>"{,<instance mode>{,<owner id>}});

so I wrote this down and it still doesnt work

.@instance_id = instance_create(.@instance$,2,$PartyA);

[Error]: instance_create: party 1 not found for instance 'Babylon Arena'.

 

 

so my main question is, how do I attach $PartyB to $PartyA's instanceID so that I can teleport PartyB to PartyA's dungeon map

prontera,156,192,4	script	ArenaPVP	469,{
	// Important Variables
	.@instance$ = "Babylon Arena"; // Battleground Name
	.@npcname$ = "[^FF0000Queue for Babylon Arena^000000]"; // NPC Name
	.@requiredmembers = 2; // Required Members

	mes .@npcname$;
	
	// Checks if character's current party ID is in an instance
	//if (instance_id()) {
	//	mes "You are already participating on an instance, please make sure to leave the party before queueing.";
	//	close;
	//}
	
	// Checks if character is in a party
	if (getcharid(1) == 0) {
		mes "You are currently not in a party.";
		close;
	}
	
	// Checks if you are the party leader
	if( !getcharid(1) || getcharid(3) != getpartyleader(getcharid(1),1)){
		.@targetID = getpartyleader(getcharid(1),1);
		mes "Please inform ^FF0000"+rid2name(.@targetID)+"^000000 to queue for the battleground.";
		close;
	}
	
	// Checks if NPCMatch is full AND participating the match
	if ($NPCMatch == 2 && ($PartyA == getcharid(1) || $PartyB == getcharid(1))) {
	mes "Your match is in progress...";
	close;
	}
	
	// Checks if you have less than or more than the amount of members required
	getpartymember getcharid(1),0;
	getpartymember getcharid(1),1;
	getpartymember getcharid(1), 2;
	.@count = $@partymembercount;
	if (.@count > .@requiredmembers) {
	mes "You have exceeded the limit of "+.@requiredmembers+" to queue.";
	close;
	} else if (.@count < .@requiredmembers) {
	mes "You do not have enough members to queue.";
	close;
	}
	
	// If every checks are good, do this
	.@count = $@partymembercount;
	copyarray .@name$[0], $@partymembername$[0], $@partymembercount;
	copyarray .@cid[0], $@partymembercid[0], $@partymembercount;
	// list the party member names
	mes "Here is the list of participating members:";
	mes "^efefff_^000000";
	for (.@i = 0; .@i < .@count; .@i++)
		mes (.@i +1) + ". ^0000FF" + .@name$[.@i] + "^000000 "+.@cid[.@i];
	next;
	switch(select("Queue for Babylon Arena:Information:Reset Variables:Teleport")) {
		case 1:
			mes .@npcname$;
			
			// Party B Instance Creation
			if ($PartyA == 1) {
				.@instance_id = instance_create(.@instance$);
			
				// Check to see if instance creation failed.
				if (.@instance_id < 0) {
					switch (.@create) {
						case -1: mes "ERROR: Invalid type."; break;
						case -2: mes "ERROR: Party not found."; break;
						case -3: mes "ERROR: Instance already exists."; break;
						case -4: mes "ERROR: No free instances."; break;
					}
					mes " ";
					mes "Instance creation ^FF0000failed^000000.";
					emotion e_omg;
					close;
				}
				
				
				// Proceed to instance_create
				mes "In queue for battleground...";
				$PartyB = 1; // Occupy the Party B spot globally
				$NPCMatch = 2; // Makes $NPCMatch = 1, needs one more to queue.
				$PartyB1 = .@cid[0]; // Makes $PartyB1 the Party Member 1's charID
				$PartyB2 = .@cid[1]; // Makes $PartyB2 the Party Member 2's charID
				$InstanceIDB = instance_id();
				close2;
				//instance_enter(.@instance$,7,50,$PartyA1,$InstanceIDA);
				//instance_enter(.@instance$,7,50,$PartyA2,$InstanceIDA);
				//instance_enter(.@instance$,92,50,$PartyB1,$InstanceIDA);
				//instance_enter(.@instance$,92,50,$PartyB2,$InstanceIDA);
				end;
			}
			
			// Party A Instance Creation
			.@instance_id = instance_create(.@instance$);
			
			// Check to see if instance creation failed.
			if (.@instance_id < 0) {
				switch (.@create) {
					case -1: mes "ERROR: Invalid type."; break;
					case -2: mes "ERROR: Party not found."; break;
					case -3: mes "ERROR: Instance already exists."; break;
					case -4: mes "ERROR: No free instances."; break;
				}
				mes " ";
				mes "Instance creation ^FF0000failed^000000.";
				emotion e_omg;
				close;
			}
		
			// Proceed to instance_create
			mes "In queue for battleground...";
			$PartyA = 1; // Occupy the Party A spot globally
			$NPCMatch = 1; // Makes $NPCMatch = 1, needs one more to queue.
			$PartyA1 = .@cid[0]; // Makes $PartyA1 the Party Member 1's charID
			$PartyA2 = .@cid[1]; // Makes $PartyA2 the Party Member 2's charID
			$InstanceIDA = instance_id();
			close;
		case 2:
			mes .@npcname$;
			mes "$NPCMatch = "+$NPCMatch;
			mes "$PartyA = "+$PartyA;
			mes "$PartyB = "+$PartyB;
			mes "$PartyA1 = "+$PartyA1;
			mes "$PartyA2 = "+$PartyA2;
			mes "$PartyB1 = "+$PartyB1;
			mes "$PartyB2 = "+$PartyB2;
			mes "$InstanceIDA = "+$InstanceIDA;
			mes "$InstanceIDB = "+$InstanceIDB;
			mes "My instance_id() = "+instance_id();
			close;
		case 3:
			mes .@npcname$;
			$NPCMatch = 0;
			$PartyA = 0;
			$PartyB = 0;
			$PartyA1 = 0;
			$PartyA2 = 0;
			$PartyB1 = 0;
			$PartyB2 = 0;			
			instance_destroy instance_id();
			$InstanceIDA = 0;
			$InstanceIDB = 0;
			//party_destroy(getcharid(1)); // Disbands the party.
			mes "$NPCMatch = "+$NPCMatch;
			mes "$PartyA = "+$PartyA;
			mes "$PartyB = "+$PartyB;
			mes "$PartyA1 = "+$PartyA1;
			mes "$PartyA2 = "+$PartyA2;
			mes "$PartyB1 = "+$PartyB1;
			mes "$PartyB2 = "+$PartyB2;
			mes "$InstanceIDA = "+$InstanceIDA;
			mes "$InstanceIDB = "+$InstanceIDB;
			mes "My instance_id() = "+instance_id();
			close;
		case 4:
			instance_enter(.@instance$,7,50,$PartyA1,$InstanceIDA);
			instance_enter(.@instance$,7,50,$PartyA2,$InstanceIDA);
			instance_enter(.@instance$,92,50,$PartyB1,$InstanceIDA);
			instance_enter(.@instance$,92,50,$PartyB2,$InstanceIDA);
		close;
	}
}

here is what my NPC Script sample technically is and it's very easy to read. Need help understanding instance_create and instance_enter

Edited by Mavis
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

I am not sure but i don't think you can make a two party enter the same instance map as the other party since the map code will be different.

For your idea it's better to make it using a BG Script.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

Do you have a guide to make a BG script? I cant even find the BG UI in game lol

back then it was possible with the old src for instance which was warp(instance_mapname("arena",$InstanceIDA),0,0);

Edited by Mavis
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

https://github.com/rathena/rathena/blob/master/doc/script_commands.txt 

I also tried your idea in the past a PVP Based instance but didn't successfully made it.

Chapter 9 Battlegrounds Commands

You can ask questions in the forum (If you do not understand the commands or something)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

actually i think i got it.

i found out that you can find the "unique" mapname by using this code:
.@mname$ = instance_mapname("arena", instance_id());
mes "My map name "+.@mname$;

in my test, it resulted to 001arena, and i tried to @warp 001arena and it works lol

so my solution for warping was for PartyA to make a new variable called $mname$ = instance_mapname("arena", instance_id());  then for warp, I just did warp $mname$,x,y,$PartyA1;

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

10 minutes ago, Mavis said:

actually i think i got it.

i found out that you can find the "unique" mapname by using this code:
.@mname$ = instance_mapname("arena", instance_id());
mes "My map name "+.@mname$;

in my test, it resulted to 001arena, and i tried to @warp 001arena and it works lol

so my solution for warping was for PartyA to make a new variable called $mname$ = instance_mapname("arena", instance_id());  then for warp, I just did warp $mname$,x,y,$PartyA1;

I see that's pretty interesting :o a few instance idea suddenly came up in my mind

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

We provided constants for instance types and you went for hardcoded numbers :\

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  46
  • Topics Per Day:  0.01
  • Content Count:  147
  • Reputation:   26
  • Joined:  11/19/11
  • Last Seen:  

4 hours ago, Secrets said:

We provided constants for instance types and you went for hardcoded numbers :\

What! Where can i find these lol

 

Sorry im very outdated lol i only recently came back to RO so my knowledge was back in 2010 xD

Link to comment
Share on other sites

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.

×
×
  • Create New...