-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
132 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ![logo](https://raw.githubusercontent.com/azerothcore/azerothcore.github.io/master/images/logo-github.png) AzerothCore | ||
|
||
## mod-custom-deserter | ||
|
||
For each time a player abandons a bg, it will give them a progressive deserter time. | ||
The duration of the deserter is given by the following formula: | ||
duration = base_duration + deserter_count * base_duration | ||
|
||
Written by Nefertumm | ||
https://github.com/Nefertumm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPLv2+ license | ||
* Written by Nefertumm : https://github.com/Nefertumm | ||
*/ | ||
|
||
|
||
[worldserver] | ||
|
||
######################################## | ||
# Custom Deserter Module Configuration file | ||
######################################## | ||
# | ||
# DeserterBaseDuration | ||
# Description: Base duration for the deserter, in minutes. | ||
# Default: 30 - 30 minutes | ||
# | ||
# | ||
|
||
DeserterBaseDuration = 30 | ||
|
||
######################################## | ||
# | ||
# DeserterDays | ||
# Description: From how many days the script will start to count the amount of deserters the player had. Leave it at 0 so it counts all of them independently of time. | ||
# Default: 7 days | ||
# | ||
# | ||
|
||
DeserterDays = 7 |
This file was deleted.
Oops, something went wrong.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
DROP TABLE IF EXISTS `custom_deserter`; | ||
|
||
CREATE TABLE IF NOT EXISTS `custom_deserter` | ||
( | ||
`ID` INT unsigned AUTO_INCREMENT, | ||
`Guid` INT unsigned NOT NULL, | ||
`Time` INT unsigned NOT NULL, | ||
`Duration` INT NOT NULL, | ||
CONSTRAINT `PK_custom_deserter` PRIMARY KEY(`ID`) | ||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; | ||
|
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
/* | ||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3 | ||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPLv2+ license | ||
* Written by Nefertumm : https://github.com/Nefertumm | ||
*/ | ||
|
||
|
||
// From SC | ||
void AddMyPlayerScripts(); | ||
void AddCustomDeserterScripts(); | ||
|
||
// Add all | ||
// cf. the naming convention https://github.com/azerothcore/azerothcore-wotlk/blob/master/doc/changelog/master.md#how-to-upgrade-4 | ||
// additionally replace all '-' in the module folder name with '_' here | ||
void Addskeleton_moduleScripts() | ||
void Addmod_custom_deserterScripts() | ||
{ | ||
AddMyPlayerScripts(); | ||
AddCustomDeserterScripts(); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPLv2+ license | ||
* Written by Nefertumm : https://github.com/Nefertumm | ||
*/ | ||
|
||
#include "ScriptMgr.h" | ||
#include "CharacterDatabase.h" | ||
#include "GameTime.h" | ||
#include "Player.h" | ||
#include "Config.h" | ||
#include "Chat.h" | ||
|
||
enum SpellIds | ||
{ | ||
SPELL_DESERTER = 26013 | ||
}; | ||
|
||
class CustomDeserter : public BGScript | ||
{ | ||
public: | ||
CustomDeserter() : BGScript("CustomDeserter") { } | ||
|
||
uint32 GetDeserterCount(ObjectGuid::LowType const guid, time_t time) | ||
{ | ||
uint32 const days = sConfigMgr->GetOption<uint32>("DeserterDays", 7); | ||
time_t from = days != 0 ? time - static_cast<time_t>(days) * DAY : 0; | ||
QueryResult result = CharacterDatabase.Query("SELECT COUNT(DISTINCT Time) FROM custom_deserter WHERE Guid = {} AND Time BETWEEN {} AND {}", guid, from, time); // Fixme: OnBattlegroundRemovePlayerAtLeave is calling twice | ||
if (result) | ||
return (*result)[0].Get<uint32>(); | ||
else return 0; | ||
} | ||
|
||
void OnBattlegroundRemovePlayerAtLeave(Battleground* bg, Player* player) override | ||
{ | ||
if (!player) | ||
return; | ||
|
||
if (bg->isBattleground() && !player->IsGameMaster()) | ||
{ | ||
BattlegroundStatus status = bg->GetStatus(); | ||
if (status == STATUS_IN_PROGRESS || status == STATUS_WAIT_JOIN) | ||
{ | ||
int32 const baseDuration = sConfigMgr->GetOption<int32>("DeserterBaseDuration", 30) * MINUTE * IN_MILLISECONDS; | ||
|
||
time_t now = GameTime::GetGameTime().count(); | ||
ObjectGuid::LowType const guid = player->GetGUID().GetCounter(); | ||
// First we get the amount of deserters from db | ||
uint32 deserterCount = GetDeserterCount(guid, now); | ||
// Calculate deserter duration | ||
int32 duration = baseDuration + (deserterCount * baseDuration); | ||
|
||
// After that we check if the player already has deserter debuff | ||
if (Aura* deserterAura = player->GetAura(SPELL_DESERTER)) | ||
{ | ||
int32 auraDuration = deserterAura->GetDuration(); | ||
deserterAura->SetDuration(duration); | ||
} | ||
else | ||
{ | ||
Aura* aura = player->AddAura(SPELL_DESERTER, player); | ||
if (!aura) | ||
return; | ||
aura->SetDuration(duration); | ||
} | ||
// Save deserter to db | ||
CharacterDatabase.DirectExecute("INSERT INTO custom_deserter (Guid, Time, Duration) VALUES ({}, {}, {})", guid, now, duration); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
// Add all scripts in one | ||
void AddCustomDeserterScripts() | ||
{ | ||
new CustomDeserter(); | ||
} |