Jump to content
  • 0

Bg script help (Adding Function)


Thanna

Question


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  271
  • Reputation:   7
  • Joined:  01/06/12
  • Last Seen:  

Hello rA community, I would like to request if someone can make this BG script made by Ms. AnnieRuru to random shuffle team function she made on the BG_emp, I hope someone can help me TIA


this is the script that I want to be converted on a 1 waitingroom random shuffle team

 

-	script	custom_bg#control	-1,{
OnInit:
	set .minplayer2start, 2; // minimum player to start ... please do not set to 1
	setarray .rewarditem,
		501, 10, // reward to the winning team
		501, 3; // reward to the losing team
	set .startingscore, 15; // score at start
	set .eventlasting, 20*60; // event last 20 minutes or the system abort itself
	set .red_cloth, 1; // color value from red clothing
	set .blue_cloth, 2; // color value from blue clothing
	set .grey_cloth, 3; // color value from grey clothing
	end;
OnStart:
	if ( getwaitingroomstate( 0, .rednpcname$ ) < .minplayer2start || getwaitingroomstate( 0, .bluenpcname$ ) < .minplayer2start ) end;
	.red = waitingroom2bg( "guild_vs3", 13,50, strnpcinfo(0)+"::OnredQuit", strnpcinfo(0)+"::OnredDead", .rednpcname$ );
	copyarray .team1aid, $@arenamembers, $@arenamembersnum;
	.team1count = .minplayer2start;
	.blue = waitingroom2bg( "guild_vs3", 86,50, strnpcinfo(0)+"::OnblueQuit", strnpcinfo(0)+"::OnblueDead", .bluenpcname$ );
	copyarray .team2aid, $@arenamembers, $@arenamembersnum;
	.team2count = .minplayer2start;
	delwaitingroom .rednpcname$;
	delwaitingroom .bluenpcname$;
	bg_warp .red, "guild_vs3", 13,50;
	bg_warp .blue, "guild_vs3", 86,50;
	.score[1] = .score[2] =.startingscore;
	bg_updatescore "guild_vs3", .score[1], .score[2];
	callsub L_setleader, 1;
	callsub L_setleader, 2;
	for ( .@i = 0; .@i < .minplayer2start; .@i++ ) {
		attachrid .team1aid[.@i];
		@clotes_color = getlook( look_clothes_color );
		setlook look_clothes_color, ( .leader_aid[1] == getcharid(3) )? .grey_cloth : .red_cloth;
	}
	for ( .@i = 0; .@i < .minplayer2start; .@i++ ) {
		attachrid .team2aid[.@i];
		@clotes_color = getlook( look_clothes_color );
		setlook look_clothes_color, ( .leader_aid[2] == getcharid(3) )? .grey_cloth : .blue_cloth;
	}
	sleep .eventlasting * 1000;
	if ( .score[1] > .score[2] ) {
		mapannounce "guild_vs3", "red side wins !", 0;
		callsub L_reward, 1, 0;
		callsub L_reward, 2, 2;
	}
	else if ( .score[1] < .score[2] ) {
		mapannounce "guild_vs3", "blue side wins !", 0;
		callsub L_reward, 2, 0;
		callsub L_reward, 1, 2;
	}
	else {
		mapannounce "guild_vs3", "Draw !", 0;
		callsub L_reward, 1, 2;
		callsub L_reward, 2, 2;
	}
	bg_warp .red, "prontera",152,178;
	bg_warp .blue, "prontera",154,178;
	bg_destroy .red;
	bg_destroy .blue;
	donpcevent .rednpcname$ +"::OnStart";
	donpcevent .bluenpcname$ +"::OnStart";
	.leader_aid[1] = .leader_aid[2] = 0;
	for ( .@i = 0; .@i < .team1count; .@i++ ) {
		attachrid .team1aid[.@i];
		setlook look_clothes_color, @clotes_color;
		@clotes_color = 0;
	}
	for ( .@i = 0; .@i < .team2count; .@i++ ) {
		attachrid .team2aid[.@i];
		setlook look_clothes_color, @clotes_color;
		@clotes_color = 0;
	}
	end;
L_reward:
	for ( .@i = 0; .@i < getd(".team"+ getarg(0) +"count"); .@i++ )
		getitem .rewarditem[ getarg(1) ], .rewarditem[ getarg(1) +1 ], getd(".team"+ getarg(0) +"aid["+ .@i +"]" );
	return;
OnredDead: callsub L_dead, 1;
OnblueDead: callsub L_dead, 2;
L_dead:
	if ( .leader_aid[ getarg(0) ] != getcharid(3) )
		.score[ getarg(0) ]--;
	else {
		callsub L_setleader, getarg(0);
		.score[ getarg(0) ] -= 2;
	}
	bg_updatescore "guild_vs3", .score[1], .score[2];
	if ( .score[ getarg(0) ] <= 0 )
		awake strnpcinfo(0);
	sleep2 1250;
	percentheal 100,100;
	end;
OnredQuit: callsub L_quit, 1, .red;
OnblueQuit: callsub L_quit, 2, .blue;
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 ( .leader_aid[ getarg(0) ] == getcharid(3) )
		callsub L_setleader, getarg(0);
	setlook look_clothes_color, @clotes_color;
	@clotes_color = 0;
	if ( bg_get_data( getarg(1), 0 ) > 1 ) end;
	.score[ getarg(0) ] = 0;
	awake strnpcinfo(0);
	end;
L_setleader:
	while ( ( .@tmp = getd( ".team"+ getarg(0) +"aid["+ rand( getd(".team"+ getarg(0) +"count") ) +"]" ) ) == playerattached() );
	.leader_aid[ getarg(0) ] = .@tmp;
	.@origin = playerattached();
	attachrid .leader_aid[ getarg(0) ];
	addtimer 1, strnpcinfo(0) +"::Onteam"+ getarg(0) +"leader";
	attachrid .@origin;
	return;
Onteam1leader: callsub L_lead, 1, 548;
Onteam2leader: callsub L_lead, 2, 549;
L_lead:
	while ( .leader_aid[ getarg(0) ] == getcharid(3) ) {
		specialeffect2 getarg(1);
		sleep2 1000;
	}
	end;
}

prontera,152,178,5	script	red side	733,{
	end;
OnInit:
	set getvariableofnpc( .rednpcname$, "custom_bg#control" ), strnpcinfo(0);
OnStart:
	waitingroom "Red Team", getvariableofnpc( .minplayer2start, "custom_bg#control" ) +1, "custom_bg#control::OnStart", getvariableofnpc( .minplayer2start, "custom_bg#control" );
	end;
}
prontera,154,178,5	script	blue side	734,{
	end;
OnInit:
	set getvariableofnpc( .bluenpcname$, "custom_bg#control" ), strnpcinfo(0);
OnStart:
	waitingroom "Blue Team", getvariableofnpc( .minplayer2start, "custom_bg#control" ) +1, "custom_bg#control::OnStart", getvariableofnpc( .minplayer2start, "custom_bg#control" );
	end;
}
guild_vs3	mapflag	battleground	2
guild_vs3	mapflag	nosave	SavePoint
guild_vs3	mapflag	nowarp
guild_vs3	mapflag	nowarpto
guild_vs3	mapflag	noteleport
guild_vs3	mapflag	nomemo
guild_vs3	mapflag	nopenalty
guild_vs3	mapflag	nobranch
guild_vs3	mapflag	noicewall

 

 

and this is the script Ms. AnnieRUru made with the 1 waitingroom and random shuffle team function

 

new_4-2,100,108,4	script	Battlegrounds Trans	418,{
	end;
OnStart:
	getmapxy .@map$, .@x, .@y, 1;
	warpwaitingpc .@map$, .@x, .@y;
	callfunc "rand__", .minplayer2start *2, $@rand;
	for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ )
		setbgid ( .@i % 2 )? .red : .blue, $@warpwaitingpc[ $@rand[.@i] ];
	delwaitingroom strnpcinfo(0);
	bg_warp .red, "bat_c01", 50,124;
	bg_warp .blue, "bat_c01", 149,59;
	setwall "bat_c01",54,122,6,7,0,"batc01wall_a";
	setwall "bat_c01",55,122,5,7,0,"batc01wall_b";
	setwall "bat_c01",140,56,6,7,0,"batc01wall_c";
	setwall "bat_c01",140,57,5,7,0,"batc01wall_d";
	bg_updatescore "bat_c01", 0, 0;
	sleep 6000;
	areapercentheal "bat_c01",50,123,58,131,100,100;
	areapercentheal "bat_c01",141,52,149,60,100,100;
	mapannounce "bat_c01", "Rules are simple. The first one to break the opponent's emperium will get a score.", 0;
	sleep 3000;
	mapannounce "bat_c01", "Score "+ .winningscore +" rounds to win ! ... GET READY", 0;
	while (1) {
		for ( .@i = 5; .@i > 0; .@i-- ) {
			mapannounce "bat_c01","[ "+ .@i +" ]", 0;
			sleep 1000;
		}
		if ( .score[1] == .winningscore -1 && .score[2] == .winningscore -1 )
			mapannounce "bat_c01", "Final Round start!", 0;
		else
			mapannounce "bat_c01", "Round "+ .round++ +" Start!", 0;
		bg_monster .red,"bat_c01",50,131, "--ja--",1915, strnpcinfo(0)+"::OnRedDown";
		bg_monster .blue,"bat_c01",149,52, "--ja--",1914, strnpcinfo(0)+"::OnBlueDown";
		donpcevent "::OnKvM01LightA";
		donpcevent "::OnKvM01LightB";
		donpcevent "::OnKvM01LightC";
		delwall "batc01wall_a";
		delwall "batc01wall_b";
		delwall "batc01wall_c";
		delwall "batc01wall_d";
		if ( .score[1] != .winningscore || .score[2] != .winningscore )
			sleep .eventlasting * 1000;
		.score[ .winside ]++;
		bg_updatescore "bat_c01", .score[1], .score[2];
		killmonster "bat_c01", strnpcinfo(0)+"::OnRedDown";
		killmonster "bat_c01", strnpcinfo(0)+"::OnBlueDown";
		if ( .winside && .empkiller$ != "" )
			mapannounce "bat_c01","[ "+ .empkiller$ +" ] has Destroy "+( ( .winside == 1 )?"Blue":"Red" )+" Team's Emperium. "+( ( .winside == 1 )?"Red":"Blue" )+" Team score a point !", 0;
		if ( .score[1] == .winningscore || .score[2] == .winningscore || !.winside ) break;
		sleep 5000;
		bg_warp .red, "bat_c01", 50,124;
		bg_warp .blue, "bat_c01", 149,59;
		setwall "bat_c01",54,122,6,7,0,"batc01wall_a";
		setwall "bat_c01",55,122,5,7,0,"batc01wall_b";
		setwall "bat_c01",140,56,6,7,0,"batc01wall_c";
		setwall "bat_c01",140,57,5,7,0,"batc01wall_d";
		.winside = 0;
		.empkiller$ = "";
		sleep 1000;
	}
	if ( .winside ) {
		mapannounce "bat_c01", "[ "+( ( .winside == 1 )?"Red":"Blue" )+" Team] won !", 0;
		getbgusers ( .winside == 1 )? .red : .blue;
		for ( .@i = 0; .@i < $@arenamembersnum; .@i++ )
			getitem .rewarditem[0], .rewarditem[1], $@arenamembers[.@i]; // item reward
	} else
		mapannounce "bat_c01", "Time Out. Aborting the match.", 0;
	sleep 5000;
	bg_warp .red, "new_4-2", 100,102;
	bg_warp .blue, "new_4-2", 100,102;
	bg_kickall .red;
	bg_kickall .blue;
	delwall "batc01wall_a";
	delwall "batc01wall_b";
	delwall "batc01wall_c";
	delwall "batc01wall_d";
	.round = .winside = .score[0] = .score[1] = .score[2] = 0;
	.empkiller$ = "";
	waitingroom "BG Emperium", .minplayer2start*2 +1, strnpcinfo(0) +"::OnStart", .minplayer2start*2;
	end;
OnRedDown: callsub L_EmpDown, 2;
OnBlueDown: callsub L_EmpDown, 1;
L_EmpDown:
	.empkiller$ = strcharinfo(0);
	.winside = getarg(0);
	awake strnpcinfo(0);
	end;

OnRedQuit: callsub L_quit, .red, "Red", 2;
OnBlueQuit: callsub L_quit, .blue, "Blue", 1;
L_quit:
	if ( bg_get_data( getarg(0), 0 ) ) end;
	mapannounce "bat_c01", "All "+ getarg(1) +" team members has Quit !", 0;
	.score[ getarg(2) ] = .winningscore -1;
	.winside = getarg(2);
	awake strnpcinfo(0);
	end;
	
OnRedDead:
OnBlueDead:
	sleep2 10000;
	end;

OnInit:
	.red = 3; // red team bg ID
	.blue = 4; // blue team bg ID
	set .minplayer2start, 5; // minimum player to start
	setarray .rewarditem, 12334, 1; // reward to the winning team
	set .winningscore, 2; // final score to win
	set .eventlasting, 1200; // abort the system if there's no progress, 1200 seconds = 20 mins
	createbgid .red, "bat_c01", 50,124, strnpcinfo(0)+"::OnRedQuit", strnpcinfo(0)+"::OnRedDead";
	createbgid .blue, "bat_c01", 149,59, strnpcinfo(0)+"::OnBlueQuit", strnpcinfo(0)+"::OnBlueDead";
	waitingroom "Battle Grounds", .minplayer2start*2 +1, strnpcinfo(0) +"::OnStart", .minplayer2start*2;
	end;
}



function	script	rand__	{
	.@range = getarg(0);
	.@count = getarg(2, 0);
	.@count = ( .@count == 0 || .@count > .@range )? .@range : ( .@count > 128 )? 128 : .@count;
	while ( .@i < .@count ) {
		.@r = .@save = rand( .@i, .@range -1 ) ;
		if ( getd(".@tmp1_"+ .@i ) == 0 ) {
			.@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;
}



// HEALER
// *****************************************************************
-	script	bghealbuffs	-1,{


OnPCLoadMapEVent:

if(strcharinfo(3) == "bat_c01") {

while (getbrokenid(1)) {
        repair(1);
        set .@a, .@a +1;
    }   
getinventorylist;
for (set .@j, 0; .@j < @inventorylist_count; set .@j, .@j + 1) {
    if (!@inventorylist_identify[.@j]) {
        delitem2 @inventorylist_id[.@j],1,0,0,0,0,0,0,0;
        getitem @inventorylist_id[.@j],1;
    }
}
percentheal 100,100;
skilleffect 34,0; sc_start SC_BLESSING,1800000,10;
skilleffect 29,0; sc_start SC_INCREASEAGI,1800000,10;
}
end;
}
// Light Effects
// *********************************************************************

bat_c01,54,123,0	script	#bat_c01a	111,{
	end;

OnKvM01LightA: misceffect 54; end;
OnKvM01LightB: misceffect 55; end;
OnKvM01LightC: misceffect 56; end;
}

bat_c01,56,125,0	duplicate(#bat_c01a)	#bat_c01b	111
bat_c01,58,127,0	duplicate(#bat_c01a)	#bat_c01c	111
bat_c01,141,56,0	duplicate(#bat_c01a)	#bat_c01d	111
bat_c01,143,58,0	duplicate(#bat_c01a)	#bat_c01e	111
bat_c01,145,60,0	duplicate(#bat_c01a)	#bat_c01f	111







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

 

 

Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  45
  • Topics Per Day:  0.01
  • Content Count:  271
  • Reputation:   7
  • Joined:  01/06/12
  • Last Seen:  

 

Hi, mind if you can give me a copy of the working script, I already have the diff applied because I have a BG that is made by Ms. AnnieRuru before

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