Skip to content

Commit

Permalink
Implemented the Battleground Queue System (#3995)
Browse files Browse the repository at this point in the history
* Fixes #1310.
* Added a battle config which allows toggling of the Battleground Queue client feature and also toggles between the modes of scripts.
* Added script commands bg_reserve, bg_unbook, and bg_desert.
* Removed old custom Battleground scripts.
Thanks to @Lemongrass3110, @Locien, @secretdataz, @InusualZ, @Normynator, @Atemo, @iubantot, @admkakaroto, and @noobzter003!
  • Loading branch information
aleos89 committed Feb 12, 2020
1 parent c292794 commit 2931c00
Show file tree
Hide file tree
Showing 44 changed files with 2,671 additions and 4,788 deletions.
4 changes: 4 additions & 0 deletions conf/battle/feature.conf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ feature.autotrade_sit: 1
// Delay in miliseconds to open vending/buyingsotre after player logged in.
feature.autotrade_open_delay: 5000

// Battlegrounds queue interface. Makes it possible to queue for a battleground anywhere using the battle menu.
// Requires: 2012-04-10aRagexe or later
feature.bgqueue: on

// Roulette (Note 1)
// Requires: 2014-10-22bRagexe or later
feature.roulette: on
Expand Down
5 changes: 5 additions & 0 deletions conf/msg_conf/map_msg.conf
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,11 @@
// 334: Thirty-Four Castles
334: Total Domination

// Battlegrounds Queue
337: You may not join a battleground queue when you're in a battleground map.
338: You can't apply to a battleground queue due to recently deserting a battleground. Time remaining: %d minutes and %d seconds.
339: You can't apply to a battleground queue for %d seconds due to recently leaving one.

// Templates for @who output
343: Name: %s
344: (%s)
Expand Down
174 changes: 174 additions & 0 deletions db/battleground_db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
# This file is a part of rAthena.
# Copyright(C) 2019 rAthena Development Team
# https://rathena.org - https://github.com/rathena
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
# Battleground Queue Database
###########################################################################
#
# Battleground Queue Settings
#
###########################################################################
# - Id Unique ID for the battleground type.
# Name Name of the battleground. Must be the exact same as in the client for players to be able to join.
# MinPlayers Minimum number of players required on each team. (Default: 1)
# MaxPlayers Maximum number of players on each team. (Default: MAX_BG_MEMBERS / 2)
# MinLevel Minimum level required to join the battleground. (Default: 1)
# MaxLevel Maximum level to join the battleground. (Default: MAX_LEVEL value)
# Deserter Amount of time in seconds a player is marked deserter. (Default: 600)
# StartDelay Amount of time in seconds once a queue is filled before a start message is sent to players. (Default: 30)
# Locations: Battleground location settings.
# - Map The map on which the battleground will be played.
# StartEvent NPC event triggered when the battleground starts.
# TeamA: TeamA settings.
# RespawnX X coordinate for warping on death.
# RespawnY Y coordinate for warping on death.
# DeathEvent NPC event triggered when a player dies.
# QuitEvent NPC event triggered when a player quits.
# Variable Name of BG ID variable used in the battleground script.
# TeamB: TeamB settings.
# RespawnX X coordinate for warping on death.
# RespawnY Y coordinate for warping on death.
# DeathEvent NPC event triggered when a player dies.
# QuitEvent NPC event triggered when a player quits.
# Variable Name of BG ID variable used in the battleground script.
###########################################################################

Header:
Type: BATTLEGROUND_DB
Version: 1

Body:
- Id: 1
Name: "Tierra Gorge"
MinPlayers: 6
MinLevel: 80
Locations:
- Map: "bat_a01"
StartEvent: "start#bat_a01::OnReadyCheck"
TeamA:
RespawnX: 50
RespawnY: 374
QuitEvent: "start#bat_a01::OnGuillaumeQuit"
Variable: "$@TierraBG1_id1"
TeamB:
RespawnX: 42
RespawnY: 16
QuitEvent: "start#bat_a01::OnCroixQuit"
Variable: "$@TierraBG1_id2"
- Map: "bat_a02"
StartEvent: "start#bat_a02::OnReadyCheck"
TeamA:
RespawnX: 50
RespawnY: 374
QuitEvent: "start#bat_a02::OnGuillaumeQuit"
Variable: "$@TierraBG2_id1"
TeamB:
RespawnX: 42
RespawnY: 16
QuitEvent: "start#bat_a02::OnCroixQuit"
Variable: "$@TierraBG2_id2"
- Id: 2
Name: "Flavius"
MinPlayers: 6
MinLevel: 80
Locations:
- Map: "bat_b01"
StartEvent: "start#bat_b01::OnReadyCheck"
TeamA:
RespawnX: 10
RespawnY: 290
QuitEvent: "start#bat_b01::OnGuillaumeQuit"
Variable: "$@FlaviusBG1_id1"
TeamB:
RespawnX: 390
RespawnY: 10
QuitEvent: "start#bat_b01::OnCroixQuit"
Variable: "$@FlaviusBG1_id2"
- Map: "bat_b02"
StartEvent: "start#bat_b02::OnReadyCheck"
TeamA:
RespawnX: 10
RespawnY: 290
QuitEvent: "start#bat_b02::OnGuillaumeQuit"
Variable: "$@FlaviusBG2_id1"
TeamB:
RespawnX: 390
RespawnY: 10
QuitEvent: "start#bat_b02::OnCroixQuit"
Variable: "$@FlaviusBG2_id2"
- Id: 3
Name: "KVM (Level 80 and up)"
MinPlayers: 5
MinLevel: 80
Locations:
- Map: "bat_c01"
StartEvent: "KvM01_BG::OnStart"
TeamA:
RespawnX: 52
RespawnY: 129
DeathEvent: "KvM01_BG::OnGuillaumeDie"
QuitEvent: "KvM01_BG::OnGuillaumeQuit"
Variable: "$@KvM01BG_id1"
TeamB:
RespawnX: 147
RespawnY: 55
DeathEvent: "KvM01_BG::OnCroixDie"
QuitEvent: "KvM01_BG::OnCroixQuit"
Variable: "$@KvM01BG_id2"
- Id: 4
Name: "KVM (Level 60~79)"
MinPlayers: 5
MinLevel: 60
MaxLevel: 79
Locations:
- Map: "bat_c02"
StartEvent: "KvM02_BG::OnStart"
TeamA:
RespawnX: 52
RespawnY: 129
DeathEvent: "KvM02_BG::OnGuillaumeDie"
QuitEvent: "KvM02_BG::OnGuillaumeQuit"
Variable: "$@KvM02BG_id1"
TeamB:
RespawnX: 147
RespawnY: 55
DeathEvent: "KvM02_BG::OnCroixDie"
QuitEvent: "KvM02_BG::OnCroixQuit"
Variable: "$@KvM02BG_id2"
- Id: 5
Name: "KVM (Level 59 and below"
MinPlayers: 5
MaxLevel: 59
Locations:
- Map: "bat_c03"
StartEvent: "KvM03_BG::OnStart"
TeamA:
RespawnX: 52
RespawnY: 129
DeathEvent: "KvM03_BG::OnGuillaumeDie"
QuitEvent: "KvM03_BG::OnGuillaumeQuit"
Variable: "$@KvM03BG_id1"
TeamB:
RespawnX: 147
RespawnY: 55
DeathEvent: "KvM03_BG::OnCroixDie"
QuitEvent: "KvM03_BG::OnCroixQuit"
Variable: "$@KvM03BG_id2"

Footer:
Imports:
- Path: db/import/battleground_db.yml
52 changes: 52 additions & 0 deletions db/import-tmpl/battleground_db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This file is a part of rAthena.
# Copyright(C) 2019 rAthena Development Team
# https://rathena.org - https://github.com/rathena
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###########################################################################
# Battleground Queue Database
###########################################################################
#
# Battleground Queue Settings
#
###########################################################################
# - Id Unique ID for the battleground type.
# Name Name of the battleground. Must be the exact same as in the client for players to be able to join.
# MinPlayers Minimum number of players required on each team. (Default: 1)
# MaxPlayers Maximum number of players on each team. (Default: MAX_BG_MEMBERS / 2)
# MinLevel Minimum level required to join the battleground. (Default: 1)
# MaxLevel Maximum level to join the battleground. (Default: MAX_LEVEL value)
# Deserter Amount of time in seconds a player is marked deserter. (Default: 600)
# StartDelay Amount of time in seconds once a queue is filled before a start message is sent to players. (Default: 30)
# Locations: Battleground location settings.
# - Map The map on which the battleground will be played.
# StartEvent NPC event triggered when the battleground starts.
# TeamA: TeamA settings.
# RespawnX X coordinate for warping on death.
# RespawnY Y coordinate for warping on death.
# DeathEvent NPC event triggered when a player dies.
# QuitEvent NPC event triggered when a player quits.
# Variable Name of BG ID variable used in the battleground script.
# TeamB: TeamB settings.
# RespawnX X coordinate for warping on death.
# RespawnY Y coordinate for warping on death.
# DeathEvent NPC event triggered when a player dies.
# QuitEvent NPC event triggered when a player quits.
# Variable Name of BG ID variable used in the battleground script.
###########################################################################

Header:
Type: BATTLEGROUND_DB
Version: 1
47 changes: 44 additions & 3 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9305,7 +9305,8 @@ QMARK_PURPLE - Purple Marker
*waitingroom2bg_single(<battle group>,{"<map name>",<x>,<y>{,"<npc name>"}});

Adds the first waiting player from the chat room of the given NPC to an existing battleground group.
The player will also be warped to the default spawn point of the battle group or to the specified coordinates <x> and <y> on the given <map>.
The player will also be warped to the default spawn point of the battle group or to the specified coordinates
<x> and <y> on the given <map>.

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

Expand Down Expand Up @@ -9349,15 +9350,17 @@ Returns battle group ID on success. Returns 0 on failure.

*bg_join(<battle group>,{"<map name>",{<x>,<y>{,<char id>}});

Adds an attached player or <char id> if specified to an existing battleground group. The player will also be warped to the default spawn point of the battle group or to the specified coordinates <x> and <y> on the given <map>.
Adds an attached player or <char id> if specified to an existing battleground group. The player will also be warped
to the default spawn point of the battle group or to the specified coordinates <x> and <y> on the given <map>.

Returns true on success. Returns false on failure.

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

*bg_team_setxy <Battle Group ID>,<x>,<y>;

Updates the respawn point of the given Battle Group to x,y on the same map. <Battle Group ID> can be retrieved using getcharid(4).
Updates the respawn point of the given Battle Group to x,y on the same map. <Battle Group ID> can be retrieved
using getcharid(4).

Example:
bg_team_setxy getcharid(4),56,212;
Expand All @@ -9366,6 +9369,29 @@ Example:

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

*bg_reserve("<battleground_name>");

Reserves a slot for the given Battleground for the Battleground UI System.

Note: 'bg_reserve' and 'bg_unbook' prevent the Battlegrounds queue from joining players in an active Battleground.

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

*bg_unbook("<battleground_name>");

Removes a spot for the given Battleground for the Battleground UI System.

Note: 'bg_reserve' and 'bg_unbook' prevent the Battlegrounds queue from joining players in an active Battleground.

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

*bg_desert({<char_id>});

Same as 'bg_leave' but slaps the player with a deserter status so they can't enter another queue for the time
defined in battleground_db (10 minutes by default).

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

*bg_warp <Battle Group>,"<map name>",<x>,<y>;

Similar to the 'warp' command.
Expand Down Expand Up @@ -9469,6 +9495,21 @@ mapflag <map name> battleground 2

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

*bg_info("<battleground name>", <type>);

Retrieves data related to given <battleground name> from the database. Requires feature.bgqueue
to be enabled. <Type> can be one of the following:

BG_INFO_ID: Battleground ID.
BG_INFO_REQUIRED_PLAYERS: Required players to start a battleground (per side).
BG_INFO_MAX_PLAYERS: Maximum players allowed in a battleground.
BG_INFO_MIN_LEVEL: Minimum level allowed to join a battleground.
BG_INFO_MAX_LEVEL: Maximum level allowed to join a battleground.
BG_INFO_MAPS: Number of maps in a battleground. Stores an array of map names in @bgmaps[] and a count in @bgmapscount.
BG_INFO_DESERTER_TIME: Amount of time in seconds a player is marked deserter.

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

====================
|10.- Pet commands.|
====================
Expand Down
Loading

8 comments on commit 2931c00

@mazvi
Copy link
Contributor

@mazvi mazvi commented on 2931c00 Feb 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this feature limit/restrict same IP?

@aleos89
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't recall this being an official feature, so it would have to be added separately if people really need it. Anyone is welcome to open a PR!

@akiyamamio16
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this be better if it's feature branch?

@Lemongrass3110
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this be better if it's feature branch?

It has been for a long time now.

@Tolimatoi
Copy link

@Tolimatoi Tolimatoi commented on 2931c00 Feb 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The map server may crash in different cases.
example.
when changing the MinPlayers 6> 1 map-server crash: free(): invalid pointer.

If the queue exceeds the existence time [20s] and someone accepts the queue map-server crash:
[Error]: Server received crash signal! Attempting to save all online characters!

sorry for my bad english.

@Balferian
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tolimatoi did you test it with this pull?
#4648

@Tolimatoi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tolimatoi did you test it with this pull?
#4648

Sorry, I will test it.

@Stingor
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not look eamod bg friendly xd

Please sign in to comment.