Skip to content

Commit

Permalink
Adds support for macro detection (rathena#7315)
Browse files Browse the repository at this point in the history
* Adds the official client macro detection system.
* Includes the ability to load imagery at server boot.
* See doc/captcha_db.txt for more information!
Thanks to @Asheraf and @Lemongrass3110!
Co-authored-by: Lemongrass3110 <[email protected]>
  • Loading branch information
aleos89 authored Oct 14, 2022
1 parent 750c7d7 commit d7bf5eb
Show file tree
Hide file tree
Showing 19 changed files with 883 additions and 5 deletions.
10 changes: 10 additions & 0 deletions conf/battle/client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,13 @@ show_skill_scale: yes
// Note: Enabling this is known to cause problems on clients that make use of REST API calls.
// Official: no
drop_connection_on_quit: no

// Macro Detector retries
// Number of times someone can fail the macro detection before being banned.
// Official: 3 (minimum: 1)
macro_detection_retry: 3

// Macro Detector timeout
// Amount of time in milliseconds before the macro detection will fail and the user will be banned.
// Official: 60000
macro_detection_timeout: 60000
2 changes: 2 additions & 0 deletions conf/groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Body:
hack_info: true
any_warp: true
view_hpmeter: true
macro_detect: true
- Id: 99
Name: Admin
Level: 99
Expand All @@ -238,6 +239,7 @@ Body:
item_unconditional: false
bypass_stat_onclone: true
bypass_max_stat: true
macro_register: true
#all_permission: true

Footer:
Expand Down
37 changes: 37 additions & 0 deletions db/captcha_db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This file is a part of rAthena.
# Copyright(C) 2022 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/>.
#
###########################################################################
# Captcha Database Table
###########################################################################
#
# Captcha Database Settings
#
###########################################################################
# - Id Index value.
# Filename Name of the BMP image file (with location).
# Answer Correct answer for the captcha (case-sensitive).
# Bonus Bonus Script ran on success. (Default: Level 10 Blessing and Increase Agility)
###########################################################################

Header:
Type: CAPTCHA_DB
Version: 1

Footer:
Imports:
- Path: db/import/captcha_db.yml
33 changes: 33 additions & 0 deletions db/import-tmpl/captcha_db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# This file is a part of rAthena.
# Copyright(C) 2022 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/>.
#
###########################################################################
# Captcha Database Table
###########################################################################
#
# Captcha Database Settings
#
###########################################################################
# - Id Index value.
# Filename Name of the BMP image file (with location).
# Answer Correct answer for the captcha (case-sensitive).
# Bonus Bonus Script ran on success. (Default: Level 10 Blessing and Increase Agility)
###########################################################################

Header:
Type: CAPTCHA_DB
Version: 1
44 changes: 44 additions & 0 deletions doc/captcha_db.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//===== rAthena Documentation ================================
//= Captcha Database Structure
//===== By: ==================================================
//= rAthena Dev Team
//===== Last Updated: ========================================
//= 20220920
//===== Description: =========================================
//= Explanation of the captcha_db.yml file and structure.
//============================================================

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

Id: Unique ID.

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

Filename: Name of the BMP image file (with location).
The path of the file can be different for each captcha image, but it's best practice to keep them in the same directory.

Example:
Filename: db/import/captcha/rathena.bmp

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

Answer: Correct answer for the captcha (case-sensitive).

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

Bonus: NPC script that is ran when a captcha is successfully answered. Accepts all forms of script constants, variables, as well as the
unique player variable @captcha_retries. This variable can be used within the Bonus script to get the remaining retries a player
has. Coupled with the script command 'getbattleflag()' this could be used to assign different bonuses based on success rate.

Example:
# Give level 10 Blessing for 20 minutes with no failures, else give for 30 seconds.
Bonus: >
if (@captcha_retries == getbattleflag("macro_detection_retry")) {
# Player solved it on first try
specialeffect2 EF_BLESSING;
sc_start SC_BLESSING,1200000,10;
} else {
# Player needed more than one try
specialeffect2 EF_BLESSING;
sc_start SC_BLESSING,30000,10;
}
12 changes: 12 additions & 0 deletions doc/permissions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,15 @@ Allow to bypass the maximum stat parameter (at conf/player.conf) to
maximum value 32,767.

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

*macro_detect

Allows player to use the client command /macro_detector.

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

*macro_register

Allows player to use the client commands /maco_register (used to add new captcha) and /macro_preview (used to preview captcha by ID).

---------------------------------------
2 changes: 1 addition & 1 deletion src/map/atcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3268,7 +3268,7 @@ ACMD_FUNC(recall) {

if ( pc_get_group_level(sd) < pc_get_group_level(pl_sd) )
{
clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to preform this action on the specified player.
clif_displaymessage(fd, msg_txt(sd,81)); // Your GM level doesn't authorize you to perform this action on the specified player.
return -1;
}

Expand Down
2 changes: 2 additions & 0 deletions src/map/battle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10270,6 +10270,8 @@ static const struct _battle_data {
{ "feature.barter", &battle_config.feature_barter, 1, 0, 1, },
{ "feature.barter_extended", &battle_config.feature_barter_extended, 1, 0, 1, },
{ "break_mob_equip", &battle_config.break_mob_equip, 0, 0, 1, },
{ "macro_detection_retry", &battle_config.macro_detection_retry, 3, 1, INT_MAX, },
{ "macro_detection_timeout", &battle_config.macro_detection_timeout, 60000, 0, INT_MAX, },

#include "../custom/battle_config_init.inc"
};
Expand Down
2 changes: 2 additions & 0 deletions src/map/battle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ struct Battle_Config
int feature_barter;
int feature_barter_extended;
int break_mob_equip;
int macro_detection_retry;
int macro_detection_timeout;

#include "../custom/battle_config_struct.inc"
};
Expand Down
Loading

0 comments on commit d7bf5eb

Please sign in to comment.