Jump to content
  • 0

Battle Ground Emperium


Radian

Question


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

Hello, can someone help me out with this script

 

what i want is to put @joinbg command on this.. works like Battle Conquest of eAmod how it announce how many players join/need to start the Battle Ground.

 

here's the script im using

//===== rAthena Script =======================================
//= Battleground: Emperium
//===== By: ==================================================
//= AnnieRuru
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: =====================================
//= rAthena Project
//===== Description: =========================================
//= A simple battleground script:
//= Destroy the opponent's Emperium to win the match.
//===== Additional Comments: =================================
//= 1.0 First version, edited. [Euphy]
//============================================================

-	script	bg_emp#control	-1,{
OnInit:
	.minplayer2start = 5;      // minimum players to start (ex. if 3vs3, set to 3)
	.eventlasting    = 20*60;  // event duration before auto-reset (20 minutes * seconds)
	setarray .rewarditem[0],   // rewards for the winning team: <item>,<amount>,...
		501, 10;

	.team1name$ = "Red";
	.team2name$ = "Blue";
	end;
OnStart:
	if ( getwaitingroomstate( 0, .rednpcname$ ) < .minplayer2start || getwaitingroomstate( 0, .bluenpcname$ ) < .minplayer2start )
		end;

	// create Battleground and teams
	.red = waitingroom2bg( "bat_a01", 157,347, strnpcinfo(0)+"::OnRedQuit", strnpcinfo(0)+"::OnRedDead", .rednpcname$ );
	copyarray .team1aid, $@arenamembers, $@arenamembersnum;
	.team1count = .minplayer2start;
	.blue = waitingroom2bg( "bat_a01", 142,51, strnpcinfo(0)+"::OnBlueQuit", strnpcinfo(0)+"::OnBlueDead", .bluenpcname$ );
	copyarray .team2aid, $@arenamembers, $@arenamembersnum;
	.team2count = .minplayer2start;
	delwaitingroom .rednpcname$;
	delwaitingroom .bluenpcname$;
	disablenpc .rednpcname$;
	disablenpc .bluenpcname$;
	setwall "bat_a01", 164,347, 6, 4, 0, "bg_emp_town_red";
	setwall "bat_a01", 154,51, 6, 4, 0, "bg_emp_town_blue";
	bg_warp .red, "bat_a01", 171,346;
	bg_warp .blue, "bat_a01", 162,50;
	bg_updatescore "bat_a01", 0, 0;

	// delay before match begins
	sleep 6000;
	mapannounce "bat_a01", "The rules are simple. The first team to break the opponent's Emperium wins!", bc_map;
	sleep 3000;
	for ( .@i = 5; .@i > 0; .@i-- ) {
		mapannounce "bat_a01", "["+ .@i +"]", bc_map;
		sleep 1000;
	}
	mapannounce "bat_a01", "Start!", bc_map;

	// spawn Emperiums
	bg_monster .red,"bat_a01",171,346, "--ja--",1288, strnpcinfo(3)+"::OnRedDown";
	bg_monster .blue,"bat_a01",162,50, "--ja--",1288, strnpcinfo(3)+"::OnBlueDown";
	delwall "bg_emp_town_red";
	delwall "bg_emp_town_blue";

	// match duration
	sleep .eventlasting * 1000;

	// end match, destroy Battleground, reset NPCs
	killmonster "bat_a01", strnpcinfo(3)+"::OnRedDown";
	killmonster "bat_a01", strnpcinfo(3)+"::OnBlueDown";
	if ( .winside ) {
		mapannounce "bat_a01", "- "+ getd( ".team"+ .winside +"name$" ) +" Team is victorious! -", bc_map;
		for ( .@i = 0; .@i < getd(".team"+ .winside +"count"); .@i++ )
			getitem .rewarditem[0], .rewarditem[1], getd(".team"+ .winside +"aid["+ .@i +"]" );
	} else
		mapannounce "bat_a01", "- The match has ended in a draw! -", bc_map;
	sleep 5000;
	bg_warp .red, "mellina", 86,80;
	bg_warp .blue, "mellina", 86,80;
	bg_destroy .red;
	bg_destroy .blue;
	delwall "bg_emp_town_red";
	delwall "bg_emp_town_blue";
	deletearray .team1aid;
	deletearray .team2aid;
	.winside = .team1count = .team2count = 0;
	enablenpc .rednpcname$;
	enablenpc .bluenpcname$;
	donpcevent .rednpcname$ +"::OnStart";
	donpcevent .bluenpcname$ +"::OnStart";
	end;

// Emperium destroyed
OnRedDown:  callsub L_EmpDown, 1, 2;
OnBlueDown: callsub L_EmpDown, 2, 1;
L_EmpDown:
	mapannounce "bat_a01", strcharinfo(0) +" has destroyed "+ getd( ".team"+ getarg(0) +"name$" ) +" Team's Emperium.", bc_map;
	.winside = getarg(1);
	awake strnpcinfo(0);
	end;

// "OnDeath" event
OnRedDead:
OnBlueDead:
	sleep2 1250;
	percentheal 100,100;
	end;

// "OnQuit" event
OnRedQuit:  callsub L_Quit, 1, 2;
OnBlueQuit: callsub L_Quit, 2, 1;
L_Quit:
	percentheal 100, 100;
	while ( getd( ".team"+ getarg(0) +"aid["+ .@i +"]" ) != getcharid(3) && .@i < getd(".team"+ getarg(0) +"count") ) .@i++;
	deletearray getd( ".team"+ getarg(0) +"aid["+ .@i +"]" ), 1;
	setd ".team"+ getarg(0) +"count", getd(".team"+ getarg(0) +"count") -1;
	if ( getd(".team"+ getarg(0) +"count") ) end;
	mapannounce "bat_a01", "All "+ getd( ".team"+ getarg(0) +"name$" ) +" team members have quit!", bc_map, 0xff3333;
	end;
}

turbo_room,106,117,3	script	Red Team#bg_emp	733,{
	end;
OnInit:
	sleep 1;
	set getvariableofnpc( .rednpcname$, "bg_emp#control" ), strnpcinfo(0);
OnStart:
	waitingroom "Red Team", getvariableofnpc( .minplayer2start, "bg_emp#control" ) +1, "bg_emp#control::OnStart", getvariableofnpc( .minplayer2start, "bg_emp#control" );
	end;
}

turbo_room,93,117,5	script	Blue Team#bg_emp	734,{
	end;
OnInit:
	sleep 1;
	set getvariableofnpc( .bluenpcname$, "bg_emp#control" ), strnpcinfo(0);
OnStart:
	waitingroom "Blue Team", getvariableofnpc( .minplayer2start, "bg_emp#control" ) +1, "bg_emp#control::OnStart", getvariableofnpc( .minplayer2start, "bg_emp#control" );
	end;
}

bat_a01	mapflag	battleground
bat_a01	mapflag	nosave	SavePoint
bat_a01	mapflag	nowarp
bat_a01	mapflag	nowarpto
bat_a01	mapflag	noteleport
bat_a01	mapflag	nomemo
bat_a01	mapflag	nopenalty
bat_a01	mapflag	nobranch
bat_a01	mapflag	noicewall

Link to comment
Share on other sites

11 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

@bump

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

 

thanks for the reply but it was set on guild_vs3 map 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

try this one

source

http://rathena.org/board/topic/72571-battleground-system-without-waitingroom/

function

function	script	rand__	{
	.@range = getarg(0);
	.@count = getarg(2, 0);
	if ( !.@count || .@count > .@range )
		.@count = .@range;
	else if ( .@count > 128 )
		.@count = 128;
	while ( .@i < .@count ) {
		.@r = .@save = rand( .@i, .@range -1 ) ;
		if ( !getd( ".@tmp1_"+ .@i ) ) {
			.@r = ( getd(".@tmp1_"+ .@r ) )? getd( ".@tmp2_"+ .@r ) : .@r;
			setd ".@tmp2_"+ .@i, .@r;
			setd ".@tmp2_"+ .@save , .@i;
			setd ".@tmp1_"+ .@save , 1;
			set getelementofarray( getarg(1), .@i ), .@r;
			if ( .@save < .@count )
				set getelementofarray( getarg(1), .@save ), .@i;
		}
		.@i++;
	}
	return .@count;
}
script

[paste=2z0keg2hdm4]

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

Thank you for the reply..

 

I've tested the script with the source code. i got no error on compiling.

 

but when i tested it 

 

Player 1 use (joinbg) = its ok there's a debug message that he already sign up

 

Player 2 use (joinbg) = its ok the debug message shows but only the player 1 warp on the BG area.

Edited by Ginji
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

ahhhhhh .....

that script was tested fine in hercules,

and yes this script will bug in rathena because rathena haven't fix this bug yet

http://hercules.ws/board/tracker/issue-8008-copyarray-fail-on-a-referenced-array-argument/?gopid=21876#entry21876

use this script instead

[paste=ik9doyac29j]

EDIT: Line 40~46 should be comment

this one ... 0.3

[paste=6z9qpbg0p5uc]

those lines has been commented

and fix the bug that this event cannot run immediately after the round ended while the registration is full

and fix another bug that when player went into another event map, caused the registration array messed up

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

It's working fine now.. 

 

Is it possible that i can change the reward prize into a custom variable?

Edited by Ginji
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

L_reward:
	getbgusers getarg(0);
	for ( .@i = 0; .@i < $@arenamembersnum; .@i++ )
		for ( .@j = 0; .@j < getarg(2); .@j += 2 )
			getitem getelementofarray( getarg(1), .@j ), getelementofarray( getarg(1), .@j +1 ), $@arenamembers[.@i];
	return;
change into

L_reward:
	getbgusers getarg(0);
	for ( .@i = 0; .@i < $@arenamembersnum; .@i++ ) {
		attachrid $@arenamembers[.@i];
		YourVariable += 10;
	}
	detachrid;
	return;
Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

L_reward:
	getbgusers getarg(0);
	for ( .@i = 0; .@i < $@arenamembersnum; .@i++ )
		for ( .@j = 0; .@j < getarg(2); .@j += 2 )
			getitem getelementofarray( getarg(1), .@j ), getelementofarray( getarg(1), .@j +1 ), $@arenamembers[.@i];
	return;
change into

L_reward:
	getbgusers getarg(0);
	for ( .@i = 0; .@i < $@arenamembersnum; .@i++ ) {
		attachrid $@arenamembers[.@i];
		YourVariable += 10;
	}
	detachrid;
	return;

 

Thanks for the fast reply annie :) 

 

1 question. should i delete this line?

setarray .rewarditem[0],   // rewards for the winning team: <item>,<amount>,...
		501, 10;
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

don't have to, but its fine to delete it

or don't delete it also runs fine

delete it also can

don't delete also can

up to you

and anything it works

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.05
  • Content Count:  1546
  • Reputation:   192
  • Joined:  07/23/14
  • Last Seen:  

don't have to, but its fine to delete it

or don't delete it also runs fine

delete it also can

don't delete also can

up to you

and anything it works

 

lol thanks for the info :) 

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...