Skip to content
Permalink
Browse files

Implemented the Battleground Queue System (#3995)

* 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 2931c00bd483e823250c224a8b7738b4d7f260d6
Showing with 2,671 additions and 4,788 deletions.
  1. +4 −0 conf/battle/feature.conf
  2. +5 −0 conf/msg_conf/map_msg.conf
  3. +174 −0 db/battleground_db.yml
  4. +52 −0 db/import-tmpl/battleground_db.yml
  5. +44 −3 doc/script_commands.txt
  6. +53 −24 npc/battleground/flavius/flavius01.txt
  7. +53 −24 npc/battleground/flavius/flavius02.txt
  8. +35 −58 npc/battleground/flavius/flavius_enter.txt
  9. +42 −14 npc/battleground/kvm/kvm01.txt
  10. +41 −13 npc/battleground/kvm/kvm02.txt
  11. +40 −12 npc/battleground/kvm/kvm03.txt
  12. +65 −34 npc/battleground/kvm/kvm_enter.txt
  13. +4 −10 npc/battleground/kvm/kvm_item_pay.txt
  14. +55 −24 npc/battleground/tierra/tierra01.txt
  15. +55 −24 npc/battleground/tierra/tierra02.txt
  16. +35 −62 npc/battleground/tierra/tierra_enter.txt
  17. +0 −1,288 npc/custom/battleground/unofficial/bg_common.txt
  18. +0 −428 npc/custom/battleground/unofficial/bg_flavius_01.txt
  19. +0 −428 npc/custom/battleground/unofficial/bg_flavius_02.txt
  20. +0 −378 npc/custom/battleground/unofficial/bg_kvm01.txt
  21. +0 −378 npc/custom/battleground/unofficial/bg_kvm02.txt
  22. +0 −378 npc/custom/battleground/unofficial/bg_kvm03.txt
  23. +0 −476 npc/custom/battleground/unofficial/bg_tierra_01.txt
  24. +0 −476 npc/custom/battleground/unofficial/bg_tierra_02.txt
  25. +13 −0 src/common/utilities.hpp
  26. +39 −0 src/map/battle.cpp
  27. +1 −0 src/map/battle.hpp
  28. +1,286 −131 src/map/battleground.cpp
  29. +122 −23 src/map/battleground.hpp
  30. +202 −4 src/map/clif.cpp
  31. +10 −2 src/map/clif.hpp
  32. +13 −1 src/map/clif_packetdb.hpp
  33. +1 −0 src/map/map-server.vcxproj
  34. +6 −3 src/map/map.cpp
  35. +1 −1 src/map/mob.hpp
  36. +14 −4 src/map/pc.cpp
  37. +7 −1 src/map/pc.hpp
  38. +159 −76 src/map/script.cpp
  39. +11 −0 src/map/script_constants.hpp
  40. +3 −0 src/map/skill.cpp
  41. +20 −4 src/map/status.cpp
  42. +3 −0 src/map/status.hpp
  43. +2 −5 tools/ci/npc.bat
  44. +1 −1 tools/ci/npc.sh
@@ -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
@@ -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)
@@ -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
@@ -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
@@ -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>.

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

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

7 comments on commit 2931c00

@mazvi

This comment has been minimized.

Copy link
Contributor

mazvi replied Feb 12, 2020

Can this feature limit/restrict same IP?

@aleos89

This comment has been minimized.

Copy link
Contributor Author

aleos89 replied Feb 12, 2020

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

This comment has been minimized.

Copy link

akiyamamio16 replied Feb 14, 2020

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

@Lemongrass3110

This comment has been minimized.

Copy link
Member

Lemongrass3110 replied Feb 14, 2020

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

It has been for a long time now.

@Tolimatoi

This comment has been minimized.

Copy link

Tolimatoi replied Feb 19, 2020

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

This comment has been minimized.

Copy link
Contributor

Balferian replied Feb 19, 2020

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

@Tolimatoi

This comment has been minimized.

Copy link

Tolimatoi replied Feb 20, 2020

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

Sorry, I will test it.

Please sign in to comment.
You can’t perform that action at this time.