feat. Move awards to database and enable races/classes (#27)
* feat. Move awards to database and enable races/classes * feat. Allow multiple records in the table * feat. Check that the values in the register are greater than zero
This commit is contained in:
parent
5961c1bd12
commit
8e4aef41dc
8 changed files with 162 additions and 266 deletions
|
|
@ -1,49 +0,0 @@
|
|||
### TITLE
|
||||
## Type(Scope/Subscope): Commit ultra short explanation
|
||||
## |---- Write below the examples with a maximum of 50 characters ----|
|
||||
## Example 1: fix(DB/SAI): Missing spell to NPC Hogger
|
||||
## Example 2: fix(CORE/Raid): Phase 2 of Ragnaros
|
||||
## Example 3: feat(CORE/Commands): New GM command to do something
|
||||
|
||||
|
||||
### DESCRIPTION
|
||||
## Explain why this change is being made, what does it fix etc...
|
||||
## |---- Write below the examples with a maximum of 72 characters per lines ----|
|
||||
## Example: Hogger (id: 492) was not charging player when being engaged.
|
||||
|
||||
|
||||
## Provide links to any issue, commit, pull request or other resource
|
||||
## Example 1: Closes issue #23
|
||||
## Example 2: Ported from other project's commit (link)
|
||||
## Example 3: References taken from wowpedia / wowhead / wowwiki / https://wowgaming.altervista.org/aowow/
|
||||
|
||||
|
||||
|
||||
## =======================================================
|
||||
## EXTRA INFOS
|
||||
## =======================================================
|
||||
## "Type" can be:
|
||||
## feat (new feature)
|
||||
## fix (bug fix)
|
||||
## refactor (refactoring production code)
|
||||
## style (formatting, missing semi colons, etc; no code change)
|
||||
## docs (changes to documentation)
|
||||
## test (adding or refactoring tests; no production code change)
|
||||
## chore (updating bash scripts, git files etc; no production code change)
|
||||
## --------------------
|
||||
## Remember to
|
||||
## Capitalize the subject line
|
||||
## Use the imperative mood in the subject line
|
||||
## Do not end the subject line with a period
|
||||
## Separate subject from body with a blank line
|
||||
## Use the body to explain what and why rather than how
|
||||
## Can use multiple lines with "-" for bullet points in body
|
||||
## --------------------
|
||||
## More info here https://www.conventionalcommits.org/en/v1.0.0-beta.2/
|
||||
## =======================================================
|
||||
## "Scope" can be:
|
||||
## CORE (core related, c++)
|
||||
## DB (database related, sql)
|
||||
## =======================================================
|
||||
## "Subscope" is optional and depends on the nature of the commit.
|
||||
## =======================================================
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
[worldserver]
|
||||
|
||||
###################################################################################################
|
||||
# CONGRATS ON LEVEL-UP
|
||||
# CONGRATS ON LEVEL-UP
|
||||
###################################################################################################
|
||||
|
||||
# Enable the module? (1: true | 0: false)
|
||||
|
|
@ -9,78 +9,13 @@
|
|||
Congrats.Enable = 1
|
||||
|
||||
# Enable the Per level congratulations announcement (1: true | 0: false)
|
||||
|
||||
CongratsPerLevel.Enable = 1
|
||||
|
||||
# Announce the module when the player logs in?
|
||||
|
||||
Congrats.Announce = 1
|
||||
|
||||
# Set what the player receives at each level
|
||||
# M: Gold
|
||||
# S: SpellID to be cast on the player
|
||||
# 1: First ItemID to be given to the player
|
||||
# 2: Second ItemID to be given to the player
|
||||
# ID Acore String Message
|
||||
|
||||
# Level 10
|
||||
# 1 Gold / Blessing of Kings
|
||||
# Red Rose / TCG: Foam Sword Rack
|
||||
Congrats.L10M = 1
|
||||
Congrats.L10S = 20217
|
||||
Congrats.L101 = 3419
|
||||
Congrats.L102 = 45063
|
||||
|
||||
# Level 20
|
||||
# 10 Gold / Power Word Fortitude
|
||||
# Rag Doll / TCG: Flag of Ownership
|
||||
Congrats.L20M = 10
|
||||
Congrats.L20S = 48161
|
||||
Congrats.L201 = 5433
|
||||
Congrats.L202 = 38578
|
||||
|
||||
# Level 30
|
||||
# 15 Gold / Mark of the Wild
|
||||
# Sleeveless T-Shirt / TCG: Ogre Pinata
|
||||
Congrats.L30M = 15
|
||||
Congrats.L30S = 48469
|
||||
Congrats.L301 = 18231
|
||||
Congrats.L302 = 46780
|
||||
|
||||
# Level 40
|
||||
# 20 Gold / Blessing of Kings
|
||||
# Shadow Circuit / TCG: Carved Ogre Idol
|
||||
Congrats.L40M = 20
|
||||
Congrats.L40S = 20217
|
||||
Congrats.L401 = 31945
|
||||
Congrats.L402 = 49704
|
||||
|
||||
# Level 50
|
||||
# 25 Gold / Power Word Fortutude
|
||||
# Blood of the Mountain / TCG: Imp in a Ball
|
||||
Congrats.L50M = 25
|
||||
Congrats.L50S = 48161
|
||||
Congrats.L501 = 11382
|
||||
Congrats.L502 = 32542
|
||||
|
||||
# Level 60
|
||||
# 30 Gold / Mark of the Wild
|
||||
# Direbrew's Remote / TCG: Goblin Gumbo Kettle
|
||||
Congrats.L60M = 30
|
||||
Congrats.L60S = 48469
|
||||
Congrats.L601 = 37863
|
||||
Congrats.L602 = 33219
|
||||
|
||||
# Level 70
|
||||
# 35 Gold / Power Word Fortitude
|
||||
# Cuergo's Gold / TCG: Instant Statue Pedestal
|
||||
Congrats.L70M = 35
|
||||
Congrats.L70S = 48161
|
||||
Congrats.L701 = 9360
|
||||
Congrats.L702 = 54212
|
||||
|
||||
# Level 80
|
||||
# 100 Gold / Blessing of Kings
|
||||
# Cuergo's Gold with Worm / Haunted Momento
|
||||
Congrats.L80M = 100
|
||||
Congrats.L80S = 20217
|
||||
Congrats.L801 = 9361
|
||||
Congrats.L802 = 40110
|
||||
Congrats.Acore.String.ID = 60000
|
||||
|
|
|
|||
0
data/.gitkeep
Normal file
0
data/.gitkeep
Normal file
0
data/sql/.gitkeep
Normal file
0
data/sql/.gitkeep
Normal file
4
data/sql/db-world/col_acore_string.sql
Normal file
4
data/sql/db-world/col_acore_string.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
SET @ENTRY:=60000;
|
||||
DELETE FROM `acore_string` WHERE `entry` BETWEEN @ENTRY+0 AND @ENTRY+1;
|
||||
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES
|
||||
(@ENTRY+0, 'This server is running the |cff4CFF00CongratsOnLevel |rmodule.', '', '', '', '', '', 'Este servidor está ejecutando el módulo |cff4CFF00CongratsOnLevel|r', 'Este servidor está ejecutando el módulo |cff4CFF00CongratsOnLevel|r', '');
|
||||
20
data/sql/db-world/col_reward_items.sql
Normal file
20
data/sql/db-world/col_reward_items.sql
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
CREATE TABLE IF NOT EXISTS `mod_congrats_on_level_items` (
|
||||
`level` tinyint unsigned NOT NULL DEFAULT '0',
|
||||
`money` int unsigned NOT NULL DEFAULT '0',
|
||||
`spell` int unsigned NOT NULL DEFAULT '0',
|
||||
`itemId1` int unsigned NOT NULL DEFAULT '0',
|
||||
`itemId2` int unsigned NOT NULL DEFAULT '0',
|
||||
`race` tinyint unsigned NOT NULL DEFAULT '0',
|
||||
`class` tinyint unsigned NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
DELETE FROM `mod_congrats_on_level_items`;
|
||||
INSERT INTO `mod_congrats_on_level_items` (`level`, `money`, `spell`, `itemId1`, `itemId2`, `race`, `class`) VALUES
|
||||
(10, 1, 20217, 3419, 45063, 0, 0),
|
||||
(20, 10, 48161, 5433, 38578, 0, 0),
|
||||
(30, 15, 48469, 18231, 46780, 0, 0),
|
||||
(40, 20, 20217, 31945, 49704, 0, 0),
|
||||
(50, 25, 48161, 11382, 32542, 0, 0),
|
||||
(60, 30, 48469, 37863, 33219, 0, 0),
|
||||
(70, 35, 48161, 9360, 54212, 0, 0),
|
||||
(80, 100, 20217, 9361, 40110, 0, 0);
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
## Set a local git commit template
|
||||
git config --local commit.template ".git_commit_template.txt" ;
|
||||
|
|
@ -68,6 +68,45 @@ config file for quick modifications.
|
|||
#include "Player.h"
|
||||
#include "Chat.h"
|
||||
|
||||
struct COL
|
||||
{
|
||||
uint32 acoreMessageId;
|
||||
bool congratsAnnounce, congratsEnable;
|
||||
bool CongratsPerLevelEnable;
|
||||
};
|
||||
|
||||
COL col;
|
||||
|
||||
uint32 giveAward(Player* player)
|
||||
{
|
||||
QueryResult result = WorldDatabase.Query("SELECT * FROM `mod_congrats_on_level_items` WHERE `level`={} AND (`race`={} OR `race`=0) AND (`class`={} OR `class`=0)", player->getLevel(), player->getRace(), player->getClass());
|
||||
|
||||
uint32 money = 0;
|
||||
|
||||
if (result)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
if (fields[1].Get<uint32>() > 0)
|
||||
{
|
||||
player->ModifyMoney(fields[1].Get<uint32>() * GOLD);
|
||||
money += fields[1].Get<uint32>() * GOLD;
|
||||
}
|
||||
if (fields[2].Get<uint32>() > 0)
|
||||
player->CastSpell(player, fields[2].Get<uint32>());
|
||||
if (fields[3].Get<uint32>() > 0)
|
||||
player->AddItem(fields[3].Get<uint32>(), 1);
|
||||
if (fields[4].Get<uint32>())
|
||||
player->AddItem(fields[4].Get<uint32>(), 1);
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
return money;
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
class CongratsAnnounce : public PlayerScript
|
||||
{
|
||||
|
||||
|
|
@ -78,38 +117,15 @@ public:
|
|||
void OnLogin(Player* player)
|
||||
{
|
||||
// Announce Module
|
||||
if (sConfigMgr->GetOption<bool>("Congrats.Announce", true))
|
||||
if (col.congratsAnnounce)
|
||||
{
|
||||
std::string messageModule = "";
|
||||
switch (player->GetSession()->GetSessionDbLocaleIndex())
|
||||
{
|
||||
case LOCALE_enUS:
|
||||
case LOCALE_koKR:
|
||||
case LOCALE_frFR:
|
||||
case LOCALE_deDE:
|
||||
case LOCALE_zhCN:
|
||||
case LOCALE_zhTW:
|
||||
case LOCALE_ruRU:
|
||||
{
|
||||
messageModule = "This server is running the |cff4CFF00CongratsOnLevel |rmodule.";
|
||||
break;
|
||||
}
|
||||
case LOCALE_esES:
|
||||
case LOCALE_esMX:
|
||||
{
|
||||
messageModule = "Este servidor está ejecutando el módulo |cff4CFF00CongratsOnLevel|r";
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ChatHandler(player->GetSession()).SendSysMessage(messageModule);
|
||||
ChatHandler(player->GetSession()).SendSysMessage(col.acoreMessageId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
class CongratsOnLevel : public PlayerScript
|
||||
{
|
||||
|
||||
public:
|
||||
CongratsOnLevel() : PlayerScript("CongratsOnLevel") { }
|
||||
|
||||
|
|
@ -117,126 +133,91 @@ public:
|
|||
void OnLevelChanged(Player* player, uint8 oldLevel) override
|
||||
{
|
||||
// If enabled...
|
||||
if (sConfigMgr->GetOption<bool>("Congrats.Enable", true)) {
|
||||
if (col.congratsEnable)
|
||||
{
|
||||
uint8 level = player->getLevel();
|
||||
uint32 money = 0;
|
||||
|
||||
std::string level;
|
||||
uint32 money, item1, item2, spell;
|
||||
|
||||
if (oldLevel < 10 && player->getLevel() == 10)
|
||||
switch (level)
|
||||
{
|
||||
// Level 10
|
||||
const uint32 L101 = sConfigMgr->GetOption<uint32>("Congrats.L101", 0);
|
||||
const uint32 L102 = sConfigMgr->GetOption<uint32>("Congrats.L102", 0);
|
||||
const uint32 L10M = sConfigMgr->GetOption<uint32>("Congrats.L10M", 0);
|
||||
const uint32 L10S = sConfigMgr->GetOption<uint32>("Congrats.L10S", 0);
|
||||
case 10:
|
||||
{
|
||||
if (oldLevel < 10)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "10";
|
||||
item1 = L101;
|
||||
item2 = L102;
|
||||
money = L10M;
|
||||
spell = L10S;
|
||||
}
|
||||
else if (oldLevel < 20 && player->getLevel() == 20)
|
||||
{
|
||||
// Level 20
|
||||
const uint32 L201 = sConfigMgr->GetOption<uint32>("Congrats.L201", 0);
|
||||
const uint32 L202 = sConfigMgr->GetOption<uint32>("Congrats.L202", 0);
|
||||
const uint32 L20M = sConfigMgr->GetOption<uint32>("Congrats.L20M", 0);
|
||||
const uint32 L20S = sConfigMgr->GetOption<uint32>("Congrats.L20S", 0);
|
||||
case 20:
|
||||
{
|
||||
if (oldLevel < 20)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "20";
|
||||
item1 = L201;
|
||||
item2 = L202;
|
||||
money = L20M;
|
||||
spell = L20S;
|
||||
}
|
||||
else if (oldLevel < 30 && player->getLevel() == 30)
|
||||
{
|
||||
// Level 30
|
||||
const uint32 L301 = sConfigMgr->GetOption<uint32>("Congrats.L301", 0);
|
||||
const uint32 L302 = sConfigMgr->GetOption<uint32>("Congrats.L302", 0);
|
||||
const uint32 L30M = sConfigMgr->GetOption<uint32>("Congrats.L30M", 0);
|
||||
const uint32 L30S = sConfigMgr->GetOption<uint32>("Congrats.L30S", 0);
|
||||
case 30:
|
||||
{
|
||||
if (oldLevel < 30)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "30";
|
||||
item1 = L301;
|
||||
item2 = L302;
|
||||
money = L30M;
|
||||
spell = L30S;
|
||||
}
|
||||
else if (oldLevel < 40 && player->getLevel() == 40)
|
||||
{
|
||||
// Level 40
|
||||
const uint32 L401 = sConfigMgr->GetOption<uint32>("Congrats.L401", 0);
|
||||
const uint32 L402 = sConfigMgr->GetOption<uint32>("Congrats.L402", 0);
|
||||
const uint32 L40M = sConfigMgr->GetOption<uint32>("Congrats.L40M", 0);
|
||||
const uint32 L40S = sConfigMgr->GetOption<uint32>("Congrats.L40S", 0);
|
||||
case 40:
|
||||
{
|
||||
if (oldLevel < 40)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "40";
|
||||
item1 = L401;
|
||||
item2 = L402;
|
||||
money = L40M;
|
||||
spell = L40S;
|
||||
}
|
||||
else if (oldLevel < 50 && player->getLevel() == 50)
|
||||
{
|
||||
// Level 50
|
||||
const uint32 L501 = sConfigMgr->GetOption<uint32>("Congrats.L501", 0);
|
||||
const uint32 L502 = sConfigMgr->GetOption<uint32>("Congrats.L502", 0);
|
||||
const uint32 L50M = sConfigMgr->GetOption<uint32>("Congrats.L50M", 0);
|
||||
const uint32 L50S = sConfigMgr->GetOption<uint32>("Congrats.L50S", 0);
|
||||
case 50:
|
||||
{
|
||||
if (oldLevel < 50)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "50";
|
||||
item1 = L501;
|
||||
item2 = L502;
|
||||
money = L50M;
|
||||
spell = L50S;
|
||||
}
|
||||
else if (oldLevel < 60 && player->getLevel() == 60)
|
||||
{
|
||||
// Level 60
|
||||
const uint32 L601 = sConfigMgr->GetOption<uint32>("Congrats.L601", 0);
|
||||
const uint32 L602 = sConfigMgr->GetOption<uint32>("Congrats.L602", 0);
|
||||
const uint32 L60M = sConfigMgr->GetOption<uint32>("Congrats.L60M", 0);
|
||||
const uint32 L60S = sConfigMgr->GetOption<uint32>("Congrats.L60S", 0);
|
||||
case 60:
|
||||
{
|
||||
if (oldLevel < 60)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "60";
|
||||
item1 = L601;
|
||||
item2 = L602;
|
||||
money = L60M;
|
||||
spell = L60S;
|
||||
}
|
||||
else if (oldLevel < 70 && player->getLevel() == 70)
|
||||
{
|
||||
// Level 70
|
||||
const uint32 L701 = sConfigMgr->GetOption<uint32>("Congrats.L701", 0);
|
||||
const uint32 L702 = sConfigMgr->GetOption<uint32>("Congrats.L702", 0);
|
||||
const uint32 L70M = sConfigMgr->GetOption<uint32>("Congrats.L70M", 0);
|
||||
const uint32 L70S = sConfigMgr->GetOption<uint32>("Congrats.L70S", 0);
|
||||
case 70:
|
||||
{
|
||||
if (oldLevel < 70)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "70";
|
||||
item1 = L701;
|
||||
item2 = L702;
|
||||
money = L70M;
|
||||
spell = L70S;
|
||||
}
|
||||
else if (oldLevel < 80 && player->getLevel() == 80)
|
||||
{
|
||||
// Level 80
|
||||
const uint32 L801 = sConfigMgr->GetOption<uint32>("Congrats.L801", 0);
|
||||
const uint32 L802 = sConfigMgr->GetOption<uint32>("Congrats.L802", 0);
|
||||
const uint32 L80M = sConfigMgr->GetOption<uint32>("Congrats.L80M", 0);
|
||||
const uint32 L80S = sConfigMgr->GetOption<uint32>("Congrats.L80S", 0);
|
||||
case 80:
|
||||
{
|
||||
if (oldLevel < 80)
|
||||
{
|
||||
money = giveAward(player);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
level = "80";
|
||||
item1 = L801;
|
||||
item2 = L802;
|
||||
money = L80M;
|
||||
spell = L80S;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// If enabled...
|
||||
if (sConfigMgr->GetOption<bool>("CongratsPerLevel.Enable", true))
|
||||
if (col.CongratsPerLevelEnable)
|
||||
{
|
||||
// Issue a server notification for the player on level up.
|
||||
std::ostringstream ss;
|
||||
|
|
@ -265,7 +246,7 @@ public:
|
|||
}
|
||||
|
||||
// If level is defined, they hit a reward level.
|
||||
if (!level.empty())
|
||||
if (!level && col.CongratsPerLevelEnable)
|
||||
{
|
||||
// Issue a server notification for the player on level up.
|
||||
std::ostringstream ss;
|
||||
|
|
@ -292,16 +273,6 @@ public:
|
|||
}
|
||||
sWorld->SendServerMessage(SERVER_MSG_STRING, ss.str().c_str());
|
||||
|
||||
// Give the items to the player
|
||||
player->AddItem(item1, 1); // Defined Item 1
|
||||
player->AddItem(item2, 1); // Defined Item 2
|
||||
|
||||
// Give gold to the player
|
||||
player->ModifyMoney(money*GOLD); // Defined Gold
|
||||
|
||||
// Buff the player
|
||||
player->CastSpell(player, spell); // Defined Spell
|
||||
|
||||
// Issue a raid warning to the player
|
||||
std::ostringstream ss2;
|
||||
switch (player->GetSession()->GetSessionDbLocaleIndex())
|
||||
|
|
@ -332,8 +303,27 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class ModCongratsLevelWorldScript : public WorldScript
|
||||
{
|
||||
public:
|
||||
ModCongratsLevelWorldScript() : WorldScript("ModCongratsLevelWorldScript") { }
|
||||
|
||||
void OnBeforeConfigLoad(bool reload) override
|
||||
{
|
||||
if (!reload)
|
||||
{
|
||||
sConfigMgr->LoadModulesConfigs();
|
||||
col.acoreMessageId = sConfigMgr->GetOption<uint32>("Congrats.Acore.String.ID", 60000);
|
||||
col.congratsAnnounce = sConfigMgr->GetOption<uint32>("Congrats.Announce", 1);
|
||||
col.congratsEnable = sConfigMgr->GetOption<uint32>("Congrats.Enable", 1);
|
||||
col.CongratsPerLevelEnable = sConfigMgr->GetOption<uint32>("CongratsPerLevel.Enable", 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void AddCongratsOnLevelScripts()
|
||||
{
|
||||
new CongratsAnnounce();
|
||||
new CongratsAnnounce();
|
||||
new CongratsOnLevel();
|
||||
new ModCongratsLevelWorldScript();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue