/*
},{
name: "KVM (Level 80 and up)" //must match the name in client files
event: "bg_pvp::OnStart"
minLevel: 1
maxLevel: 150
reward: { // useless ! should be done by npc scripting
win: 0
loss: 0
draw: 0
}
minPlayers: 2 // minimum amount of players to start
maxPlayers: 30 // maximum amount of players. NOTE: I wonder why they set to 60 when MAX_BG_MEMBERS is only 30 <_<
minTeamPlayers: 999 // can I off this ? this one is bugged
delay_var: "BG_PVP_Tick" // char variable name that will store the delay for this match
maxDuration: 1 // maximum duration in minutes ... this one also bugged
fillDuration: 20 // time in seconds to wait for more applications when minimum has been reached
pGameDuration: 20 // time to wait for players to confirm their attendence after queueing process has finished
},{
*/
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 bg_pvp -1,{
OnInit:
// port over some variables from battleground.conf ... that's why this should be configure by scripting
.maxDuration = 100; /* maximum duration in minutes ... seriously ... this should be done through NPC scripting */
setarray .rewarditem[0], // rewards for the winning team:
501, 10; // <item>,<amount>
end;
OnStart:
// Note: the server pushed these variables
// for ( .@i = 0; .@i < $@bg_member_size; .@i++ )
// announce rid2name( $@bg_member[.@i] ) +" "+ $@bg_member_group[.@i] +" "+ $@bg_member_type[.@i], 0;
// that's all I need for the battleground script to work, no need to use their 12 script commands
.red = createbgid( "guild_vs3", 48,50, strnpcinfo(0)+"::OnRedQuit", strnpcinfo(0)+"::OnRedDead" );
.blue = createbgid( "guild_vs3", 52,50, strnpcinfo(0)+"::OnBlueQuit", strnpcinfo(0)+"::OnBlueDead" );
callfunc "rand__", $@bg_member_size, $@rand;
for ( .@i = 0; .@i < $@bg_member_size; .@i++ )
setbgid ( .@i % 2 )? .red : .blue, $@bg_member[ $@rand[.@i] ];
bg_warp .red, "guild_vs3", 48,50;
bg_warp .blue, "guild_vs3", 52,50;
.score[1] = bg_get_data( .red, 0 );
.score[2] = bg_get_data( .blue, 0 );
bg_updatescore "guild_vs3", .score[1], .score[2];
sleep .maxDuration * 60000;
if ( .score[1] > .score[2] ) {
mapannounce "guild_vs3", "- Red Team is victorious! -", bc_map;
callsub L_Reward, .red;
}
else if ( .score[1] < .score[2] ) {
mapannounce "guild_vs3", "- Blue Team is victorious! -", bc_map;
callsub L_Reward, .blue;
}
else
mapannounce "guild_vs3", "- The match has ended in a draw! -", bc_map;
mapwarp "guild_vs3","prontera",152,178;
bg_destroy .red;
bg_destroy .blue;
sleep 1;
bg_match_over "KVM (Level 80 and up)"; // still need a sleep ...
end;
L_Reward:
getbgusers getarg(0);
for ( .@i = 0; .@i < $@arenamembersnum; .@i++ )
getitem .rewarditem[0], .rewarditem[1], $@arenamembers[.@i]; // yeah .. I off that and use script commands here
return;
OnRedDead: callsub L_Dead, 1;
OnBlueDead: callsub L_Dead, 2;
L_Dead:
warp "Save", 0,0;
.score[ getarg(0) ]--;
bg_updatescore "guild_vs3", .score[1], .score[2];
if ( !.score[ getarg(0) ] )
awake strnpcinfo(0);
sleep2 1250;
percentheal 100,100;
bg_leave;
end;
OnRedQuit: callsub L_Quit, 1;
OnBlueQuit: callsub L_Quit, 2;
L_Quit:
.score[ getarg(0) ]--;
bg_updatescore "guild_vs3", .score[1], .score[2];
if ( !.score[ getarg(0) ] )
awake strnpcinfo(0);
percentheal 100, 100;
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