Jump to content

battleground system without waitingroom


AnnieRuru

Recommended Posts


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

from eathena

Download:

[paste=7207eo0p96gx]

new method and examples -> just visit the one in hercules forum .... lazy to copy and paste

http://hercules.ws/board/topic/4570-

Note: bg_kickall has been removed so no need to recycle the team ID

-----------------------------------------

[spoiler=OLD method - eAthena period]

Download:

battleground_16873.diff

-----------------------------------------

*createbgid <respawn map>, <respawn x>, <respawn y>, <On Quit event>, <On Death event>;

create a specific battleground ID, for the rest .... refer to doc

-----------------------------------------

*setbgid <battleground ID> {, <player name> };

player attached to the script will join the battleground team,

but if a player name ( or account ID ) is specify, will let that player join the battleground team

the command returns positive number ( > 0 ) if the function is successful

if it return negative :-

-1: the battleground team haven't create yet ... has to be create with createbgid

-2: the team already full, it reached MAX_BG_MEMBERS = 30 which can increase at src\map\battleground.h

-3: player not found ... happens when the input <player name> is not online or not found

-4: invalid battleground ID ... currently only accept ID range within 1~1000

-5: the player already join the battleground ID that you specify

if the player has joined battleground ID 500, and you use setbgid 700;

this will force the player to leave battleground ID 500 and join battleground ID 700 without any notification

only when the player joined bg ID 500, and use setbgid 500; then only the command return -5 <-- failed

setbgid 0; is equal to bg_leave;

and setbgid 0, "annie"; or setbgid 0, 2000000;

will make the player "annie" ( or account id "]2000000 ) leave the battleground team without using attachrid + bg_leave

-----------------------------------------

*getbgusers <battleground ID>;

similar to getpartymember <party ID>, 2; // <-- return account ID

this will create an array "$@arenamembers" holding all the player's account ID from the battleground team

and $@arenamembersnum is equal to bg_get_data(<battleground ID>, 0), just like $@partymembercount

-----------------------------------------

*bg_kickall <battleground ID>;

kick every player out from the battleground team

this command is counter-part from bg_destroy

-----------------------------------------

.

[spoiler=OLD method - rAthena period]-----------------------------------------

*createbgid <respawn map>, <respawn x>, <respawn y>, <On Quit event>, <On Death event>;

create a specific battleground ID, for the rest .... refer to doc

.red = createbgid( "guild_vs3", 13,50, strnpcinfo(0)+"::Onredout", strnpcinfo(0)+"::Onreddead" );
.blue = createbgid( "guild_vs3", 86,50, strnpcinfo(0)+"::Onblueout", strnpcinfo(0)+"::Onbluedead" );
-----------------------------------------

*setbgid <battleground ID> {, <player name> };

*setbgid <battleground ID> {, <player account ID> };

player attached to the script will join the battleground team,

but if a player name ( or account ID ) is specify, will let that player join the battleground team

warpwaitingpc "guild_vs3", 0,0;
for ( .@i = 0; .@i < $@warpwaitingpcnum; .@i++ )
setbgid ( .@i % 2 )? .red : .blue, $@warpwaitingpc[.@i];
the command returns positive number ( > 0 ) if the function is successful

if it return negative :-

-1: the battleground team haven't create yet ... has to be create with createbgid

-2: the team already full, it reached MAX_BG_MEMBERS = 30 which can increase at src\map\battleground.h

-3: player not found ... happens when the input <player name> is not online or not found

-5: the player already join the battleground ID that you specify

if the player has joined battleground ID 500, and you use setbgid 700;

this will force the player to leave battleground ID 500 and join battleground ID 700 without any notification

( player who same group will receive a message mention that "player xxx leaving battlefield" )

only when the player joined bg ID 500, and use setbgid 500; then only the command return -5

but the script will still continue running without posting any error, so don't worry

setbgid 0; is equal to bg_leave;

and setbgid 0, "annie"; or setbgid 0, 2000000;

will make the player "annie" ( or account id 2000000 ) leave the battleground team without using attachrid + bg_leave

-----------------------------------------

*getbgusers <battleground ID>;

similar to getpartymember <party ID>, 2; // <-- return account ID

this will create an array "$@arenamembers" holding all the player's account ID from the battleground team

and $@arenamembersnum is equal to bg_get_data(<battleground ID>, 0), just like $@partymembercount

getbgusers .red;
for ( .@i = 0; .@i < $@arenamembersnum; .@i++ )
getitem 501, 1, $@arenamembers[.@i];
-----------------------------------------

*bg_kickall <battleground ID>;

kick every player out from the battleground team

this command is counter-part from bg_destroy

-----------------------------------------

currently don't have enough samples for this new method,

because I've done a few battleground script ...

and it seems members are prefer not to use source modification ... o.o

remember these steps

  • use OnInit with createbgid
  • use setbgid to let player join
  • don't use bg_destroy command, but use bg_kickall command instead
  • remember different script use different teams, there's a limit of 30 players on each team only <- can increase at src/map/battleground.h#L10
eg: this battleground script use bg id 1 & 2, next battleground script use bg id 3 & 4  ( bg id is self generated in ascending order )

Example ...

difference is quite a lot

although both also can achieve the battleground team creation,

but its obvious the 2nd one is much much cleaner and more feature

Example :

use OnInit + createbgid, then use setbgid to attach 2 teams on the event controller npc

if your script assigned bg_id 1 & 2, then your script use bg_warp 1 ... and bg_warp 2 ...

EDITED SCRIPT :

prontera,155,181,5	script	Sample	100,{
	mes "Battlegound";
    if ( select ( "join/leave", "warp all bg members to you" ) == 1 )
        if( getcharid(4) ){
			bg_leave;
			dispbottom "Leave BG";
		}else{
			setbgid .bg_id;
			dispbottom "Joined BG";
		}
    else if ( getcharid(4) == 0 )
        dispbottom "you didn't join a battleground team";
		
    else {
        getmapxy .@map$, .@x, .@y, 0;
        bg_warp .bg_id, .@map$, .@x, .@y;
		
    }
    close;
OnInit:
    getmapxy .@map$, .@x, .@y, 1;
    .bg_id = createbgid( .@map$, .@x, .@y, "", "" );
    end;
}
the current sample script should be look like this now .... battleground will auto generate the Battle Group ID , you cant assign the ID. :)

tested and work fine in rev 17532 ...

[spoiler=Archive]

battleground_16819.diff

battleground_16873.diff

battleground_17101.diff

battleground_17102.diff

Edited by AnnieRuru
Updated Contents.
  • Upvote 4
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  31
  • Topics Per Day:  0.01
  • Content Count:  666
  • Reputation:   93
  • Joined:  04/27/12
  • Last Seen:  

Oh.. This looks very useful. I'd make a new BG, using several existing commands as well as these new ones.

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  145
  • Topics Per Day:  0.03
  • Content Count:  455
  • Reputation:   3
  • Joined:  06/19/12
  • Last Seen:  

Hi can I ask question

is it posible to use Battle ground without battle ground equips?

Link to comment
Share on other sites

  • 3 weeks later...

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

Hi can I ask question

is it posible to use Battle ground without battle ground equips?

I don't understand your question ...

do you mean cannot bring certain equipments into battleground maps ? ...

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  64
  • Topics Per Day:  0.02
  • Content Count:  180
  • Reputation:   7
  • Joined:  12/19/12
  • Last Seen:  

i can pm you for about this? i need to understand!

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  148
  • Topics Per Day:  0.03
  • Content Count:  299
  • Reputation:   6
  • Joined:  06/14/12
  • Last Seen:  

Hi can I ask question

is it posible to use Battle ground without battle ground equips?

you don't need a battleground equips to join a battleground event

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  64
  • Topics Per Day:  0.02
  • Content Count:  180
  • Reputation:   7
  • Joined:  12/19/12
  • Last Seen:  

I can use this Queue for party vs party?

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  402
  • Reputation:   89
  • Joined:  02/07/13
  • Last Seen:  

There is trouble when using createbgid

When the npc is loading, rathena windows say : 

[Error]:
script error on npc/custom/bg.txt line 48
    parse_line: need ';'
    43 :        }
    44 :        close;
    45 : OnInit:
    46 :        getmapxy .@map$, .@x, .@y, 1;
*   48 :        createbgid 1, .@map$, .@x, .@y, ""',' "";
    49 :        end;
    50 : }

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  1302
  • Reputation:   77
  • Joined:  12/04/12
  • Last Seen:  

can this use for latest svn ?

Link to comment
Share on other sites

  • 6 months later...

  • Group:  Members
  • Topic Count:  84
  • Topics Per Day:  0.02
  • Content Count:  550
  • Reputation:   9
  • Joined:  11/06/12
  • Last Seen:  

can this be used in r16797?

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

@brunoshp

it's possible ...

 

@shakto

you didnt add the source mod given .... there are 3 new script commands in the source mod made by annie.

 

@mrlongshen and erba

there should be no problem for any version to add a custom script commands.

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  20
  • Reputation:   0
  • Joined:  07/15/13
  • Last Seen:  

sorry about this .. but i cant understand how it works .. can u please give a step by step instructions .. please i realy need this ..

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

@Shakto / others who have error.

this is the updated sample script

prontera,155,181,5	script	Sample	100,{
	mes "Battlegound";
    if ( select ( "join/leave", "warp all bg members to you" ) == 1 )
        if( getcharid(4) ){
			bg_leave;
			dispbottom "Leave BG";
		}else{
			setbgid .bg_id;
			dispbottom "Joined BG";
		}
    else if ( getcharid(4) == 0 )
        dispbottom "you didn't join a battleground team";
		
    else {
        getmapxy .@map$, .@x, .@y, 0;
        bg_warp .bg_id, .@map$, .@x, .@y;
		
    }
    close;
OnInit:
    getmapxy .@map$, .@x, .@y, 1;
    .bg_id = createbgid( .@map$, .@x, .@y, "", "" );
    end;
}
 

we cant assign battleground id when we create it because the server will auto generate one.

 

current patch is tested and still working in rev 17532 ....

 

beside, you can now simply add these source mod with this 2 file. src/custom/script.inc and src/custom/script_def.inc

should be no problem for newbie to add these source mod now.

 

Link to comment
Share on other sites

  • 1 month later...

  • Group:  Developer
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  230
  • Reputation:   131
  • Joined:  11/21/11
  • Last Seen:  

remember these steps

  • use OnInit with createbgid
  • use setbgid to let player join
  • don't use bg_destroy command, but use bg_kickall command instead
  • remember different script use different teams, there's a limit of 30 players on each team only <- can increase at src/map/battleground.h#L10
eg: this battleground script use bg id 1 & 2, next battleground script use bg id 3 & 4  ( bg id is self generated in ascending order )

What's the point of recycling team ids?

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

 

remember these steps

  • use OnInit with createbgid
  • use setbgid to let player join
  • don't use bg_destroy command, but use bg_kickall command instead
  • remember different script use different teams, there's a limit of 30 players on each team only <- can increase at src/map/battleground.h#L10
eg: this battleground script use bg id 1 & 2, next battleground script use bg id 3 & 4  ( bg id is self generated in ascending order )

 

What's the point of recycling team ids?

 

 

i believe it's up to you...

if you didnt use the bg_destroy , the previous battleground group will be saved...so you dont need to create a new battleground id using the createbgid()

otherwise, the bg_kickall() seem like useless if you intend to re-create the battleground group id everytime your script run..

 

anyway it's still depend on how you want your script to work... O__O

Link to comment
Share on other sites

  • 3 months later...

  • Group:  Members
  • Topic Count:  100
  • Topics Per Day:  0.03
  • Content Count:  333
  • Reputation:   7
  • Joined:  03/01/14
  • Last Seen:  

Is this still working?

How do I install it on my Linux server? D:

Link to comment
Share on other sites

  • 2 weeks later...

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  28
  • Reputation:   1
  • Joined:  04/22/12
  • Last Seen:  

Hello every body, i have an problem check, this is my console error.

 

[Error]:  Loading NPC file: npc/custom/phow/bgregistro.txt
script error on npc/custom/phow/bgregistro.txt line 5
    parse_line: expect command, missing function name or calling undeclared function
     1 : {
     2 : //prontera,154,185,5   script  bbb     100,{
     3 :        switch ( select( "join", "watch", "manual set", "kick all" ) ) {
     4 :                case 1:
*    5 :                        's'etbgid 1;
     6 :                        close;
     7 :                case 2:
     8 :                        getbgusers 1;
     9 :                        for ( set .@i, 0; .@i < $@arenamembersnum; set .@i, .@i +1 )
    10 :                                dispbottom ( .@i +1 )+". "+ rid2name( $@arenamembers[.@i] );
 
i put the patch diff in Script.c and compile
 
my svn version is 17703 rAthena
 
srry for my bad english x.x
 
help me please.
Edited by noxty
Link to comment
Share on other sites

  • 5 weeks later...

  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  411
  • Reputation:   261
  • Joined:  04/25/12
  • Last Seen:  

I think:

 

's'etbgid 1;

 

is set bgid,1;

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  100
  • Topics Per Day:  0.03
  • Content Count:  333
  • Reputation:   7
  • Joined:  03/01/14
  • Last Seen:  

I get this error:

***************
*** 17323,17328 ****
  	return 0;
  }
  
  // declarations that were supposed to be exported from npc_chat.c
  #ifdef PCRE_SUPPORT
  BUILDIN_FUNC(defpattern);
--- 17323,17402 ----
  	return 0;
  }
  
+ //	createbgid <respawn map>, <respawn x>, <respawn y>, <On Quit event>, <On Death event>;
+ BUILDIN_FUNC(createbgid) {
+ 	unsigned int bg_id;
+ 	if ( ( bg_id = bg_create( mapindex_name2id( script_getstr(st,2) ), script_getnum(st,3), script_getnum(st,4), script_getstr(st,5), script_getstr(st,6) ) ) > 0 )
+ 		script_pushint( st, bg_id );
+ 	else
+ 		script_pushint( st, 0 );
+ 	return 0;
+ }
+ 
+ //	setbgid <battleground ID> {, <player name> };
+ //	setbgid <battleground ID> {, <player account ID> };
+ BUILDIN_FUNC(setbgid) {
+ 	unsigned int bg_id = script_getnum(st,2);
+ 	struct battleground_data *bg = bg_team_search( bg_id );
+ 	struct map_session_data *sd;
+ 	if ( script_hasdata( st, 3 ) ) {
+ 		if ( data_isstring( script_getdata(st,3) ) )
+ 			sd = map_nick2sd( script_getstr(st,3) );
+ 		else
+ 			sd = map_id2sd( script_getnum(st,3) );
+ 	} else
+ 		sd = script_rid2sd(st);
+ 	if ( !sd ) {
+ 		script_pushint( st, -3 ); // player no attach
+ 		return 0;
+ 	}
+ 	if ( !bg && bg_id > 0 ) {
+ 		script_pushint( st, -1 ); // battleground team haven't created
+ 		return 0;
+ 	}
+ 	if ( bg_id && sd->bg_id == bg_id ) {
+ 		script_pushint( st, -5 ); // the player has already join this battleground team
+ 		return 0;
+ 	}
+ 	if ( sd->bg_id )
+ 		bg_team_leave( sd, 0 );
+ 	if ( bg_id == 0 ) {
+ 		script_pushint( st, 0 );
+ 		return 0;
+ 	}
+ 	if ( !bg_team_join( bg_id, sd ) )
+ 		script_pushint( st, -2 ); // cannot join anymore, because has reached MAX_BG_MEMBERS
+ 	else
+ 		script_pushint( st, bg_id );
+ 	return 0;
+ }
+ 
+ //	getbgusers <battleground ID>;
+ BUILDIN_FUNC(getbgusers) {
+ 	struct battleground_data *bg = bg_team_search( script_getnum(st,2) );
+ 	int i;
+ 	if ( !bg ) {
+ 		script_pushint( st, -1 );
+ 		return 0;
+ 	}
+ 	for ( i = 0; bg->members[i].sd; i++ )
+ 		mapreg_setreg( reference_uid( add_str("$@arenamembers"), i ), bg->members[i].sd->bl.id );
+ 	mapreg_setreg( add_str("$@arenamembersnum"), i );
+ 	script_pushint( st, i );
+ 	return 0;
+ }
+ 
+ //	bg_kickall <battleground ID>;
+ BUILDIN_FUNC(bg_kickall) {
+ 	struct battleground_data *bg = bg_team_search( script_getnum(st,2) );
+ 	int i;
+ 	if ( bg ) {
+ 		for ( i = 0; bg->members[i].sd; i++ )
+ 			bg_team_leave( bg->members[i].sd , 0 );
+ 	}
+ 	return 0;
+ }
+ 
  // declarations that were supposed to be exported from npc_chat.c
  #ifdef PCRE_SUPPORT
  BUILDIN_FUNC(defpattern);
***************
*** 17780,17784 ****
  	BUILDIN_DEF(checkquest, "i?"),
  	BUILDIN_DEF(changequest, "ii"),
  	BUILDIN_DEF(showevent, "ii"),
  	{NULL,NULL,NULL},
  };
--- 17854,17863 ----
  	BUILDIN_DEF(checkquest, "i?"),
  	BUILDIN_DEF(changequest, "ii"),
  	BUILDIN_DEF(showevent, "ii"),
+ 
+ 	BUILDIN_DEF(createbgid,"siiss"),
+ 	BUILDIN_DEF(setbgid,"i?"),
+ 	BUILDIN_DEF(getbgusers,"i"),
+ 	BUILDIN_DEF(bg_kickall,"i"),
  	{NULL,NULL,NULL},
  };

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  100
  • Topics Per Day:  0.03
  • Content Count:  333
  • Reputation:   7
  • Joined:  03/01/14
  • Last Seen:  

Bump.

Still the same problem.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

@yuka/noxty/zell

three of you didnt apply the source mod properly ...

 

reapply the changes... 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  28
  • Reputation:   1
  • Joined:  04/22/12
  • Last Seen:  

Hello

amm

i now have an error  /pif

   parse_line: expect command, missing function name or calling undeclared func                                                                             tion
     2 :        switch ( select( "join", "watch", "manual set", "kick all" ) ) {
     3 :                case 1:
     4 :                        set bgid,1;
     5 :                        close;
     6 :                case 2:
*    7 :                        'g'etbgusers, 1;
     8 :                        for ( set .@i, 0; .@i < $@arenamembersnum; set .                                                                             @i, .@i +1 )
     9 :                                dispbottom ( .@i +1 )+". "+ rid2name( $@                                                                             arenamembers[.@i] );
    10 :                        close;
    11 :                case 3:
    12 :                        mes "input a team";

Help me please

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2346
  • Joined:  10/28/11
  • Last Seen:  

already told you  =='' 

  • You didnt apply the source mod correctly
  • You didnt recompile your server
  • unsolved error during compilation

take a break and start learning how to diff instead of keep spam same questions over and over again.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  28
  • Reputation:   1
  • Joined:  04/22/12
  • Last Seen:  

Hello 

Emistry

 

Check this my script.c i put the patch and compile my server, and i dont have any error in compilation.

 

https://www.mediafire.com/?bfvjgkyb6vsy0y2

 

 

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  100
  • Topics Per Day:  0.03
  • Content Count:  333
  • Reputation:   7
  • Joined:  03/01/14
  • Last Seen:  

already told you  =='' 

  • You didnt apply the source mod correctly
  • You didnt recompile your server
  • unsolved error during compilation

take a break and start learning how to diff instead of keep spam same questions over and over again.

This is what I've done:

1. shut server down

2.
cd /root/rAthena/
yum install patch
patch -p1 < battleground_17102.diff

3. recompile

4. start server

 

Didn't work for me, what did I do wrong? :/

 

I'm using Centos 5.9 32 bit

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
Reply to this topic...

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