Jump to content

Recommended Posts

Posted (edited)

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
  • 1 month later...
  • 3 weeks later...
Posted

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

  • 1 month later...
  • 1 month later...
Posted

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 : }

  • 6 months later...
Posted

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

  • 2 weeks later...
Posted

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

 

  • 1 month later...
Posted

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
Posted

 

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

  • 3 months later...
  • 2 weeks later...
Posted (edited)

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
  • 5 weeks later...
Posted

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},
  };

Posted

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

Posted

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.

Posted

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...